Skip to content

Commit c6bf2e7

Browse files
committed
Feedback
1 parent 361d153 commit c6bf2e7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Servers/Kestrel/Transport.Quic/src/Internal/QuicStreamContext.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.IO;
88
using System.IO.Pipelines;
99
using System.Net.Quic;
10+
using System.Runtime.ExceptionServices;
1011
using System.Threading;
1112
using System.Threading.Tasks;
1213
using Microsoft.AspNetCore.Connections;
@@ -183,12 +184,15 @@ private async Task WaitForWritesCompleted()
183184
try
184185
{
185186
await _stream.WaitForWriteCompletionAsync();
186-
Output.CancelPendingRead();
187187
}
188188
catch (Exception ex)
189189
{
190190
// Send error to DoSend loop.
191-
Transport.Output.Complete(ex);
191+
_shutdownWriteReason = ex;
192+
}
193+
finally
194+
{
195+
Output.CancelPendingRead();
192196
}
193197
}
194198

@@ -357,6 +361,13 @@ private async Task DoSend()
357361

358362
if (result.IsCanceled)
359363
{
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+
360371
break;
361372
}
362373

0 commit comments

Comments
 (0)