Skip to content
Snippets Groups Projects
Commit 88fefe9a authored by Michael Lumish's avatar Michael Lumish
Browse files

Merge pull request #4436 from jtattermusch/csharp_shutdown_test

Fix server.KillAsync() and improve abandoned call test
parents b4d93b51 d63b1d62
No related branches found
No related tags found
No related merge requests found
......@@ -61,17 +61,20 @@ namespace Grpc.Core.Tests
}
[Test]
public async Task AbandonedCall()
public async Task AbandonedCall_ServerKillAsync()
{
var readyToShutdown = new TaskCompletionSource<object>();
helper.DuplexStreamingHandler = new DuplexStreamingServerMethod<string, string>(async (requestStream, responseStream, context) =>
{
readyToShutdown.SetResult(null);
await requestStream.ToListAsync();
});
var call = Calls.AsyncDuplexStreamingCall(helper.CreateDuplexStreamingCall(new CallOptions(deadline: DateTime.UtcNow.AddMilliseconds(1))));
var call = Calls.AsyncDuplexStreamingCall(helper.CreateDuplexStreamingCall());
await readyToShutdown.Task; // make sure handler is running
channel.ShutdownAsync().Wait();
server.ShutdownAsync().Wait();
await channel.ShutdownAsync(); // channel.ShutdownAsync() works even if there's a pending call.
await server.KillAsync(); // server.ShutdownAsync() would hang waiting for the call to finish.
}
}
}
......@@ -171,6 +171,8 @@ namespace Grpc.Core
handle.CancelAllCalls();
await shutdownTcs.Task.ConfigureAwait(false);
DisposeHandle();
await Task.Run(() => GrpcEnvironment.Release()).ConfigureAwait(false);
}
internal void AddCallReference(object call)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment