File tree 1 file changed +13
-2
lines changed
src/Servers/Kestrel/Transport.Quic/src/Internal
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 7
7
using System . IO ;
8
8
using System . IO . Pipelines ;
9
9
using System . Net . Quic ;
10
+ using System . Runtime . ExceptionServices ;
10
11
using System . Threading ;
11
12
using System . Threading . Tasks ;
12
13
using Microsoft . AspNetCore . Connections ;
@@ -183,12 +184,15 @@ private async Task WaitForWritesCompleted()
183
184
try
184
185
{
185
186
await _stream . WaitForWriteCompletionAsync ( ) ;
186
- Output . CancelPendingRead ( ) ;
187
187
}
188
188
catch ( Exception ex )
189
189
{
190
190
// Send error to DoSend loop.
191
- Transport . Output . Complete ( ex ) ;
191
+ _shutdownWriteReason = ex ;
192
+ }
193
+ finally
194
+ {
195
+ Output . CancelPendingRead ( ) ;
192
196
}
193
197
}
194
198
@@ -357,6 +361,13 @@ private async Task DoSend()
357
361
358
362
if ( result . IsCanceled )
359
363
{
364
+ // WaitForWritesCompleted provides immediate notification that write-side of stream has completed.
365
+ // If the stream or connection is aborted then exception will be available to rethrow.
366
+ if ( _shutdownWriteReason != null )
367
+ {
368
+ ExceptionDispatchInfo . Throw ( _shutdownWriteReason ) ;
369
+ }
370
+
360
371
break ;
361
372
}
362
373
You can’t perform that action at this time.
0 commit comments