未验证 提交 a847ddfe 编写于 作者: R Radek Zikmund 提交者: GitHub

Fix Wrong exception for Open*Stream after connection is closed (#67342)

* Fix Wrong exception for Open*Stream after connection is closed

* Don't handle InvalidState

* Update src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicStream.cs
Co-authored-by: NNatalia Kondratyeva <knatalia@microsoft.com>
Co-authored-by: NNatalia Kondratyeva <knatalia@microsoft.com>
上级 fe0f600e
......@@ -173,6 +173,12 @@ internal MsQuicStream(MsQuicConnection.State connectionState, QUIC_STREAM_OPEN_F
GCHandle.ToIntPtr(_state.StateGCHandle),
out _state.Handle);
if (status == MsQuicStatusCodes.Aborted)
{
// connection already aborted by peer, throw relevant exception
throw ThrowHelper.GetConnectionAbortedException(connectionState.AbortErrorCode);
}
QuicExceptionHelpers.ThrowIfFailed(status, "Failed to open stream to peer.");
Debug.Assert(!Monitor.IsEntered(_state), "!Monitor.IsEntered(_state)");
......
......@@ -86,10 +86,6 @@ public async Task CloseAsync_WithPendingAcceptAndConnect_PendingAndSubsequentThr
else
{
await Assert.ThrowsAsync<QuicOperationAbortedException>(async () => await serverConnection.AcceptStreamAsync());
// TODO: ActiveIssue https://github.com/dotnet/runtime/issues/56133
// MsQuic fails with System.Net.Quic.QuicException: Failed to open stream to peer. Error Code: INVALID_STATE
//await Assert.ThrowsAsync<QuicOperationAbortedException>(async () => await OpenAndUseStreamAsync(serverConnection));
await Assert.ThrowsAsync<QuicException>(() => OpenAndUseStreamAsync(serverConnection));
}
});
......@@ -166,17 +162,8 @@ public async Task ConnectionClosedByPeer_WithPendingAcceptAndConnect_PendingAndS
// Subsequent attempts should fail
ex = await Assert.ThrowsAsync<QuicConnectionAbortedException>(() => serverConnection.AcceptStreamAsync().AsTask());
Assert.Equal(ExpectedErrorCode, ex.ErrorCode);
// TODO: ActiveIssue https://github.com/dotnet/runtime/issues/56133
// MsQuic fails with System.Net.Quic.QuicException: Failed to open stream to peer. Error Code: INVALID_STATE
if (IsMsQuicProvider)
{
await Assert.ThrowsAsync<QuicException>(() => OpenAndUseStreamAsync(serverConnection));
}
else
{
ex = await Assert.ThrowsAsync<QuicConnectionAbortedException>(() => OpenAndUseStreamAsync(serverConnection));
Assert.Equal(ExpectedErrorCode, ex.ErrorCode);
}
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册