Merge pull request #6908 from jtattermusch/csharp_send_completion_dedup

C#: dedup code for send finished handler
pull/6916/head
Jan Tattermusch 9 years ago committed by GitHub
commit dd692b34c7
  1. 2
      src/csharp/Grpc.Core/Internal/AsyncCall.cs
  2. 27
      src/csharp/Grpc.Core/Internal/AsyncCallBase.cs

@ -267,7 +267,7 @@ namespace Grpc.Core.Internal
halfcloseRequested = true; halfcloseRequested = true;
return Task.FromResult<object>(null); return Task.FromResult<object>(null);
} }
call.StartSendCloseFromClient(HandleSendCloseFromClientFinished); call.StartSendCloseFromClient(HandleSendFinished);
halfcloseRequested = true; halfcloseRequested = true;
streamingWriteTcs = new TaskCompletionSource<object>(); streamingWriteTcs = new TaskCompletionSource<object>();

@ -248,7 +248,7 @@ namespace Grpc.Core.Internal
} }
/// <summary> /// <summary>
/// Handles send completion. /// Handles send completion (including SendCloseFromClient).
/// </summary> /// </summary>
protected void HandleSendFinished(bool success) protected void HandleSendFinished(bool success)
{ {
@ -271,31 +271,6 @@ namespace Grpc.Core.Internal
} }
} }
/// <summary>
/// Handles halfclose (send close from client) completion.
/// </summary>
protected void HandleSendCloseFromClientFinished(bool success)
{
TaskCompletionSource<object> origTcs = null;
lock (myLock)
{
origTcs = streamingWriteTcs;
streamingWriteTcs = null;
ReleaseResourcesIfPossible();
}
if (!success)
{
// TODO(jtattermusch): this method is same as HandleSendFinished (only the error message differs).
origTcs.SetException(new InvalidOperationException("Sending close from client has failed."));
}
else
{
origTcs.SetResult(null);
}
}
/// <summary> /// <summary>
/// Handles send status from server completion. /// Handles send status from server completion.
/// </summary> /// </summary>

Loading…
Cancel
Save