-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Don't cache CanReuse value #35575
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
Don't cache CanReuse value #35575
Conversation
public bool CanReuse { get; private set; } | ||
// We only want to reuse a stream that was not aborted and has completely finished writing. | ||
// This ensures Http2OutputProducer.ProcessDataWrites is in the correct state to be reused. | ||
public bool CanReuse => !_connectionAborted && HasResponseCompleted; | ||
|
||
protected override void OnReset() |
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.
Would resetting the value to false
in OnReset accomplish the same goal?
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.
The line on 44 was effectively doing that before. The issue was that !_connectionAborted && HasResponseCompleted
was being evaluated too early on a background thread and a RST_STREAM
frame could still be processed and abort the stream before pooling. Now CanReuse
is evaluated once in the main frame-processing loop right before it's pooled or not.
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.
Please add a unit test. This is subtle behavior and we want to ensure it isn't regressed in the future.
Where is _connectionAborted
set to true? Will it always happen before the stream is pooled? I want to make sure there is no chance that a stream is pooled and then some code aborts it while it is in the pool.
When the RST_STREAM is processed. |
I would also love that if you find a good way to do it @JamesNK. The problem is the This would be easy enough to do by adding some sort of event/resettable-Task we could hook in the tests when |
Ok. If we can't add a unit test then we should comment. Something like:
|
Nice catch! |
Why is this is main and not rc1? |
@davidfowl merge to main, then backport to rc1 (standard procedure I believe) |
/backport to release/6.0-rc1 |
Started backporting to release/6.0-rc1: https://github.com/dotnet/aspnetcore/actions/runs/1164353234 |
Fixes #34768
Regression?
Risk
Worst case is that Http2 streams are pooled less often.
Verification
Packaging changes reviewed?