Skip to content
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

fix MsQuicStream counting on failure #54249

Merged
merged 1 commit into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -99,6 +98,8 @@ internal MsQuicStream(MsQuicConnection.State connectionState, SafeMsQuicStreamHa
throw new ObjectDisposedException(nameof(QuicConnection));
}

_state.ConnectionState = connectionState;

if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(
Expand All @@ -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
{
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand All @@ -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);
Expand All @@ -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.
Expand Down