aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2016-05-23 13:24:39 -0400
committerGravatar Jan Tattermusch <jtattermusch@google.com>2016-05-23 15:13:26 -0400
commit239fce134426d73eb8d433f618f22aab10821826 (patch)
tree18bee9411f35a9e2920129e3f7cac20dc75a59d0 /src/csharp
parent8472cc5bc5428b5006b9ca608d399159d7daeee1 (diff)
simplify implementation of SendCloseFromClient
Diffstat (limited to 'src/csharp')
-rw-r--r--src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs2
-rw-r--r--src/csharp/Grpc.Core/Internal/AsyncCall.cs14
-rw-r--r--src/csharp/Grpc.Core/Internal/AsyncCallBase.cs2
3 files changed, 8 insertions, 10 deletions
diff --git a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs
index ae9dd6a6bf..b4dd2c107e 100644
--- a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs
+++ b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs
@@ -395,7 +395,7 @@ namespace Grpc.Core.Internal.Tests
}
[Test]
- public void DuplexStreaming_CompleteAfterReceivingStatusFails()
+ public void DuplexStreaming_CompleteAfterReceivingStatusSuceeds()
{
asyncCall.StartDuplexStreamingCall();
var requestStream = new ClientRequestStream<string, string>(asyncCall);
diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs
index ab194121a7..ad690bd2ec 100644
--- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs
+++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs
@@ -254,17 +254,15 @@ namespace Grpc.Core.Internal
GrpcPreconditions.CheckState(started);
CheckSendingAllowed(allowFinished: true);
- if (!disposed && !finished)
- {
- call.StartSendCloseFromClient(HandleSendCloseFromClientFinished);
- }
- else
+ if (disposed || finished)
{
// In case the call has already been finished by the serverside,
- // the halfclose has already been done implicitly, so we only
- // emit the notification for the completion delegate.
- Task.Run(() => HandleSendCloseFromClientFinished(true));
+ // the halfclose has already been done implicitly, so just return
+ // completed task here.
+ halfcloseRequested = true;
+ return Task.FromResult<object>(null);
}
+ call.StartSendCloseFromClient(HandleSendCloseFromClientFinished);
halfcloseRequested = true;
streamingWriteTcs = new TaskCompletionSource<object>();
diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs
index df313cbb73..13f6309f6e 100644
--- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs
+++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs
@@ -158,7 +158,7 @@ namespace Grpc.Core.Internal
if (readingDone)
{
// the last read that returns null or throws an exception is idempotent
- // and maintain its state.
+ // and maintains its state.
GrpcPreconditions.CheckState(streamingReadTcs != null, "Call does not support streaming reads.");
return streamingReadTcs.Task;
}