-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
make Quic AcceptStreamAsync concurrent safe #56768
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsI found this while investigating #55249 contributes to #55249 cc: @JamesNK
|
Ah, I didn't realize AcceptStreamAsync wasn't thread-safe. In the real-world, Kestrel will only have one call to AcceptStreamAsync active at a time. In some errors from that test the exception said that multiple ReadAsync calls at a time weren't supported. I guess in that situation one Up to you whether to make AcceptStreamAsync thread-safe or throw a more user-friendly error on multiple concurrent calls (like QuicStream.ReadAsync does). I can modify the test to be more real-world. |
If I update the test to lock the code that calls await asyncLock.WaitAsync();
try
{
serverStream = await requestState.ServerConnection.AcceptAsync();
}
finally
{
asyncLock.Release();
} |
src/libraries/System.Net.Quic/tests/FunctionalTests/QuicStreamTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicConnection.cs
Show resolved
Hide resolved
The accept failure should have no impact on the reading state. I will proceed with this change and I'll keep it watching for a while. I suspect that some other issue may be lurking out there - we are just lucky because of changed timing. |
With old |
no, I don't think so @CarnaViire. This what the |
I found this while investigating #55249
While I could rarely reproduce the reported issue, I would often see strange timeout.
With the current code, running
AcceptStreamAsync
in parallel is not safe.Thanks to @stephentoub who pointed the right place when we would throw
OperationCancelledException
without token expiring.With the change, I'm yet to see the
InvalidOperationException
. (not really sure why)contributes to #55249
I'm not sure if this really matters to runtime tests but the local runs seems happier. (not enough samples yet)
cc: @JamesNK