consider cancelRequested flag too

pull/21202/head
Jan Tattermusch 5 years ago
parent 7eeb1e564d
commit 06b420d314
  1. 4
      src/csharp/Grpc.Core/Internal/AsyncCall.cs

@ -599,6 +599,7 @@ namespace Grpc.Core.Internal
TaskCompletionSource<object> delayedStreamingWriteTcs = null;
bool releasedResources;
bool origCancelRequested;
lock (myLock)
{
finished = true;
@ -610,6 +611,7 @@ namespace Grpc.Core.Internal
}
releasedResources = ReleaseResourcesIfPossible();
origCancelRequested = cancelRequested;
}
if (releasedResources)
@ -626,7 +628,7 @@ namespace Grpc.Core.Internal
if (status.StatusCode != StatusCode.OK)
{
streamingResponseCallFinishedTcs.SetException(new RpcException(status, receivedStatus.Trailers));
if (status.StatusCode == StatusCode.Cancelled)
if (status.StatusCode == StatusCode.Cancelled || origCancelRequested)
{
// Make sure the exception set to the Task is observed,
// otherwise this can trigger "Unobserved exception" when the response stream

Loading…
Cancel
Save