Skip to content
Permalink
Browse files

Fix race condition between disposal and cancellation of CancellationT…

…okenSource (Issue #942) (#943)
  • Loading branch information...
ggeurts authored and kblok committed Mar 1, 2019
1 parent db2753d commit 69798e443c97b0fd4041db73260fff4b35a14390
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/PuppeteerSharp/Transport/WebSocketTransport.cs
@@ -85,7 +85,16 @@ public Task SendAsync(string message)
/// <summary>
/// Stops reading incoming data.
/// </summary>
public void StopReading() => _readerCancellationSource.Cancel();
public void StopReading()
{
if (!IsClosed)
{
// No need to cancel reading if no reading operation is in progress. Moreover,
// the _readerCancellationSource may already have been disposed, so cancelling
// it could cause an ObjectDisposedException.
_readerCancellationSource.Cancel();
}
}

/// <summary>
/// Starts listening the socket

0 comments on commit 69798e4

Please sign in to comment.
You can’t perform that action at this time.