File tree Expand file tree Collapse file tree 2 files changed +11
-14
lines changed
DotNext.Tests/Net/Multiplexing
cluster/DotNext.Net.Cluster/Net/Multiplexing Expand file tree Collapse file tree 2 files changed +11
-14
lines changed Original file line number Diff line number Diff line change @@ -267,4 +267,11 @@ public static async Task WaitForDisposedConnectionAsync()
267267
268268 await ThrowsAsync < ObjectDisposedException > ( Func . Constant ( task ) ) ;
269269 }
270+
271+ [ Fact ]
272+ public static async Task WaitForCanceledConnectionAsync ( )
273+ {
274+ await using var client = new TcpMultiplexedClient ( LocalEndPoint , new ( ) { Timeout = DefaultTimeout } ) ;
275+ await ThrowsAnyAsync < OperationCanceledException > ( client . OpenStreamAsync ( new CancellationToken ( canceled : true ) ) . AsTask ) ;
276+ }
270277}
Original file line number Diff line number Diff line change @@ -89,24 +89,14 @@ public ValueTask StartAsync(CancellationToken token = default)
8989 /// <seealso cref="DotNext.IO.Pipelines.DuplexStream"/>
9090 public async ValueTask < IDuplexPipe > OpenStreamAsync ( CancellationToken token = default )
9191 {
92- for ( var stream = OpenStream ( out var addedStreamId ) ; ; token . ThrowIfCancellationRequested ( ) )
93- {
94- try
95- {
96- await EnsureConnectedAsync ( token ) . ConfigureAwait ( false ) ;
97- return stream ;
98- }
99- catch ( Exception e )
100- {
101- input . TryRemoveStream ( addedStreamId , stream ) ;
102- await stream . AbortAppSideAsync ( e ) . ConfigureAwait ( false ) ;
103- }
104- }
92+ await EnsureConnectedAsync ( token ) . ConfigureAwait ( false ) ;
93+ return OpenStream ( ) ;
10594 }
10695
107- private MultiplexedStream OpenStream ( out uint id )
96+ private MultiplexedStream OpenStream ( )
10897 {
10998 var stream = new MultiplexedStream ( options , writeSignal ) ;
99+ uint id ;
110100 do
111101 {
112102 id = Interlocked . Increment ( ref streamId ) ;
You can’t perform that action at this time.
0 commit comments