-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve abort handling #41263
Improve abort handling #41263
Conversation
@@ -159,6 +159,11 @@ private async Task WriteBody(bool flush = false) | |||
{ | |||
while (true) | |||
{ | |||
if (_bodyOutput.Aborted) | |||
{ | |||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really sure this break here is ok, as I'm not really sure what the expectations are before/after this loop, is this what you had in mind @Tratcher ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have tests explicitly checking that Writes after abort no-op, so I don't think we want to throw exceptions right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, Write shouldn't throw.
I think this check needs to be after ReadAsync or you'd miss an Abort that happened while waiting for data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, there might be an issue if AdvanceTo isn't called? Moving this check inside the Try block would cover that with the finally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we always calling Complete on the pipe? If we don't there's a memory leak.
@@ -159,6 +159,11 @@ private async Task WriteBody(bool flush = false) | |||
{ | |||
while (true) | |||
{ | |||
if (_bodyOutput.Aborted) | |||
{ | |||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, there might be an issue if AdvanceTo isn't called? Moving this check inside the Try block would cover that with the finally.
You can skip AdvanceTo if you call Complete. Complete must always be called. |
The complete call is in the finally outside of the while loop, so I think we are good there. So should we just break at the top? I think the only question is where this new check for aborted needs to go |
I think the current version is fine. The important part is that the abort check is after ReadAsync. |
Fixes #31404