aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-11-30 10:54:42 -0800
committerGravatar Yash Tibrewal <yashkt@google.com>2017-11-30 10:54:42 -0800
commit10f2790f7fedb7b54889c9ba8297a9e127edb143 (patch)
tree899151af9bc4ab60aac48ab67de4e84c1cd8062a /src/csharp/Grpc.Core/Internal/ServerRequestStream.cs
parentc354269ba7bd1f6dfe9c86ba18f38fc8e346dcfc (diff)
parent5f662537deb01539a204273977c7e32394fc3454 (diff)
Merge branch 'master' into execctx
Diffstat (limited to 'src/csharp/Grpc.Core/Internal/ServerRequestStream.cs')
-rw-r--r--src/csharp/Grpc.Core/Internal/ServerRequestStream.cs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs b/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs
index c65b960afb..058dddb7eb 100644
--- a/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs
+++ b/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs
@@ -49,13 +49,14 @@ namespace Grpc.Core.Internal
public async Task<bool> MoveNext(CancellationToken token)
{
- if (token != CancellationToken.None)
+
+ var cancellationTokenRegistration = token.CanBeCanceled ? token.Register(() => call.Cancel()) : (IDisposable) null;
+ using (cancellationTokenRegistration)
{
- throw new InvalidOperationException("Cancellation of individual reads is not supported.");
+ var result = await call.ReadMessageAsync().ConfigureAwait(false);
+ this.current = result;
+ return result != null;
}
- var result = await call.ReadMessageAsync().ConfigureAwait(false);
- this.current = result;
- return result != null;
}
public void Dispose()