Skip to content

Commit

Permalink
stop reading output pipe if the previous read is cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
kerryjiang committed Jan 1, 2025
1 parent 7305207 commit 7deb9a5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/SuperSocket.Connection/PipeConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ protected virtual async Task ProcessSends()

while (true)
{
var completed = await ProcessOutputRead(output).ConfigureAwait(false);
var completedOrCancelled = await ProcessOutputRead(output).ConfigureAwait(false);

if (completed)
if (completedOrCancelled)
{
break;
}
Expand Down Expand Up @@ -153,7 +153,7 @@ protected async ValueTask<bool> ProcessOutputRead(PipeReader reader)
{
var result = await reader.ReadAsync(CancellationToken.None).ConfigureAwait(false);

var completed = result.IsCompleted;
var completedOrCancelled = result.IsCompleted || result.IsCanceled;

var buffer = result.Buffer;
var end = buffer.End;
Expand All @@ -178,7 +178,7 @@ protected async ValueTask<bool> ProcessOutputRead(PipeReader reader)
}

reader.AdvanceTo(end);
return completed;
return completedOrCancelled;
}

protected abstract ValueTask<int> SendOverIOAsync(ReadOnlySequence<byte> buffer, CancellationToken cancellationToken);
Expand Down

0 comments on commit 7deb9a5

Please sign in to comment.