From 73052072e8fda18448df0493a987b9f81a36bd69 Mon Sep 17 00:00:00 2001 From: Kerry Jiang Date: Tue, 31 Dec 2024 23:21:50 -0800 Subject: [PATCH] CancelPendingRead for output pipe --- src/SuperSocket.Connection/PipeConnection.cs | 5 +++++ src/SuperSocket.Connection/PipeConnectionBase.cs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/SuperSocket.Connection/PipeConnection.cs b/src/SuperSocket.Connection/PipeConnection.cs index ac7778455..ead5ab92e 100644 --- a/src/SuperSocket.Connection/PipeConnection.cs +++ b/src/SuperSocket.Connection/PipeConnection.cs @@ -205,5 +205,10 @@ protected override bool IsIgnorableException(Exception e) return false; } + + protected override void CancelOutputPendingRead() + { + this.Output.Reader.CancelPendingRead(); + } } } diff --git a/src/SuperSocket.Connection/PipeConnectionBase.cs b/src/SuperSocket.Connection/PipeConnectionBase.cs index 436254b59..6da0ddcd2 100644 --- a/src/SuperSocket.Connection/PipeConnectionBase.cs +++ b/src/SuperSocket.Connection/PipeConnectionBase.cs @@ -147,6 +147,7 @@ protected async Task CancelAsync() _cts.Cancel(); await CompleteWriterAsync(OutputWriter, _isDetaching).ConfigureAwait(false); + CancelOutputPendingRead(); } protected virtual bool IsIgnorableException(Exception e) @@ -438,5 +439,9 @@ protected virtual async ValueTask CompleteWriterAsync(PipeWriter writer, bool is { await writer.CompleteAsync().ConfigureAwait(false); } + + protected virtual void CancelOutputPendingRead() + { + } } }