Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ private async Task SendAsyncCore(ArraySegment<byte> buffer, WebSocketMessageType

if (sendTask != null) // this is optimization for single-threaded build, see resolvedPromise() in web-socket.ts. Null means synchronously resolved.
{
await CancellationHelper(sendTask, cancellationToken, previousState, pinBuffer).ConfigureAwait(false);
await CancellationHelper(sendTask, cancellationToken, previousState).ConfigureAwait(false);
}
}
catch (JSException ex)
Expand Down Expand Up @@ -442,7 +442,7 @@ private async Task<WebSocketReceiveResult> ReceiveAsyncCore(ArraySegment<byte> b

if (receiveTask != null) // this is optimization for single-threaded build, see resolvedPromise() in web-socket.ts. Null means synchronously resolved.
{
await CancellationHelper(receiveTask, cancellationToken, previousState, pinBuffer).ConfigureAwait(false);
await CancellationHelper(receiveTask, cancellationToken, previousState).ConfigureAwait(false);
}

return ConvertResponse();
Expand Down Expand Up @@ -550,13 +550,12 @@ private async Task CloseAsyncCore(WebSocketCloseStatus closeStatus, string? stat
}
}

private async Task CancellationHelper(Task promise, CancellationToken cancellationToken, WebSocketState previousState, IDisposable? disposable = null)
private async Task CancellationHelper(Task promise, CancellationToken cancellationToken, WebSocketState previousState)
{
try
{
if (promise.IsCompletedSuccessfully)
{
disposable?.Dispose();
return;
}
if (promise.IsCompleted)
Expand Down Expand Up @@ -602,10 +601,6 @@ private async Task CancellationHelper(Task promise, CancellationToken cancellati
throw new WebSocketException(WebSocketError.NativeError, ex);
}
}
finally
{
disposable?.Dispose();
}
}

// needs to be called with locked _lockObject
Expand Down
Loading