aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2017-10-04 16:58:32 +0200
committerGravatar GitHub <noreply@github.com>2017-10-04 16:58:32 +0200
commit8e2e9a6d91b45069651f5331dee9bff757126be8 (patch)
tree3a8858425ecd19a9d9c1455daf39db532082640e /src
parentf9a39ac7e227cc44091984631ec2e923c152f969 (diff)
parent5e8c48669ffcd14469184bcc708a994b2eaa85a4 (diff)
Merge pull request #12817 from jtattermusch/fixregister_backport
C# De-register cancellation token for v1.7.x branch
Diffstat (limited to 'src')
-rw-r--r--src/csharp/Grpc.Core/Internal/AsyncCall.cs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs
index 17109de587..09fb722c81 100644
--- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs
+++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs
@@ -34,6 +34,9 @@ namespace Grpc.Core.Internal
readonly CallInvocationDetails<TRequest, TResponse> details;
readonly INativeCall injectedNativeCall; // for testing
+ // Dispose of to de-register cancellation token registration
+ IDisposable cancellationTokenRegistration;
+
// Completion of a pending unary response if not null.
TaskCompletionSource<TResponse> unaryResponseTcs;
@@ -320,6 +323,7 @@ namespace Grpc.Core.Internal
protected override void OnAfterReleaseResources()
{
details.Channel.RemoveCallReference(this);
+ cancellationTokenRegistration?.Dispose();
}
protected override bool IsClient
@@ -405,7 +409,7 @@ namespace Grpc.Core.Internal
var token = details.Options.CancellationToken;
if (token.CanBeCanceled)
{
- token.Register(() => this.Cancel());
+ cancellationTokenRegistration = token.Register(() => this.Cancel());
}
}