未验证 提交 472f11c1 编写于 作者: T Tomas Weinfurt 提交者: GitHub

fix MsQuicStream counting on failure (#54249)

上级 f721cf41
......@@ -74,7 +74,6 @@ private sealed class State
internal MsQuicStream(MsQuicConnection.State connectionState, SafeMsQuicStreamHandle streamHandle, QUIC_STREAM_OPEN_FLAGS flags)
{
_state.Handle = streamHandle;
_state.ConnectionState = connectionState;
_canRead = true;
_canWrite = !flags.HasFlag(QUIC_STREAM_OPEN_FLAGS.UNIDIRECTIONAL);
_started = true;
......@@ -99,6 +98,8 @@ internal MsQuicStream(MsQuicConnection.State connectionState, SafeMsQuicStreamHa
throw new ObjectDisposedException(nameof(QuicConnection));
}
_state.ConnectionState = connectionState;
if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(
......@@ -113,10 +114,8 @@ internal MsQuicStream(MsQuicConnection.State connectionState, QUIC_STREAM_OPEN_F
{
Debug.Assert(connectionState.Handle != null);
_state.ConnectionState = connectionState;
_canRead = !flags.HasFlag(QUIC_STREAM_OPEN_FLAGS.UNIDIRECTIONAL);
_canWrite = true;
_stateHandle = GCHandle.Alloc(_state);
try
{
......@@ -146,6 +145,8 @@ internal MsQuicStream(MsQuicConnection.State connectionState, QUIC_STREAM_OPEN_F
throw new ObjectDisposedException(nameof(QuicConnection));
}
_state.ConnectionState = connectionState;
if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(
......@@ -569,7 +570,6 @@ private void Dispose(bool disposing)
Marshal.FreeHGlobal(_state.SendQuicBuffers);
if (_stateHandle.IsAllocated) _stateHandle.Free();
CleanupSendState(_state);
Debug.Assert(_state.ConnectionState != null);
_state.ConnectionState?.RemoveStream(this);
if (NetEventSource.Log.IsEnabled())
......
......@@ -116,7 +116,6 @@ public async Task ConnectWithCertificateChain()
}
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/52048")]
public async Task WaitForAvailableUnidirectionStreamsAsyncWorks()
{
using QuicListener listener = CreateQuicListener(maxUnidirectionalStreams: 1);
......@@ -126,7 +125,7 @@ public async Task WaitForAvailableUnidirectionStreamsAsyncWorks()
using QuicConnection serverConnection = await listener.AcceptConnectionAsync();
await clientTask;
// No stream openned yet, should return immediately.
// No stream opened yet, should return immediately.
Assert.True(clientConnection.WaitForAvailableUnidirectionalStreamsAsync().IsCompletedSuccessfully);
// Open one stream, should wait till it closes.
......@@ -141,7 +140,6 @@ public async Task WaitForAvailableUnidirectionStreamsAsyncWorks()
}
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/52048")]
public async Task WaitForAvailableBidirectionStreamsAsyncWorks()
{
using QuicListener listener = CreateQuicListener(maxBidirectionalStreams: 1);
......@@ -151,7 +149,7 @@ public async Task WaitForAvailableBidirectionStreamsAsyncWorks()
using QuicConnection serverConnection = await listener.AcceptConnectionAsync();
await clientTask;
// No stream openned yet, should return immediately.
// No stream opened yet, should return immediately.
Assert.True(clientConnection.WaitForAvailableBidirectionalStreamsAsync().IsCompletedSuccessfully);
// Open one stream, should wait till it closes.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册