Skip to content

Commit

Permalink
eliminate a thread switch when invoking server-side handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jtattermusch committed May 9, 2016
1 parent 92a9156 commit 65ca9dc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/csharp/Grpc.Core/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,18 +283,18 @@ private async Task HandleCallAsync(ServerRpcNew newRpc)
/// </summary>
private void HandleNewServerRpc(bool success, BatchContextSafeHandle ctx)
{
Task.Run(AllowOneRpc);

if (success)
{
ServerRpcNew newRpc = ctx.GetServerRpcNew(this);

// after server shutdown, the callback returns with null call
if (!newRpc.Call.IsInvalid)
{
Task.Run(async () => await HandleCallAsync(newRpc)).ConfigureAwait(false);
HandleCallAsync(newRpc); // we don't need to await.
}
}

AllowOneRpc();
}

/// <summary>
Expand Down

0 comments on commit 65ca9dc

Please sign in to comment.