Wait for server connection to end (#11256)
This commit is contained in:
parent
ab52a1d3ed
commit
b47b3e5ac6
|
|
@ -37,6 +37,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var serverConnectionCompletedTcs = new TaskCompletionSource<object>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
||||||
|
|
||||||
async Task EchoServer(ConnectionContext connection)
|
async Task EchoServer(ConnectionContext connection)
|
||||||
{
|
{
|
||||||
// For graceful shutdown
|
// For graceful shutdown
|
||||||
|
|
@ -63,6 +65,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
{
|
{
|
||||||
Logger.LogDebug("Graceful shutdown triggered for {connectionId}.", connection.ConnectionId);
|
Logger.LogDebug("Graceful shutdown triggered for {connectionId}.", connection.ConnectionId);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
serverConnectionCompletedTcs.TrySetResult(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var hostBuilder = TransportSelector.GetWebHostBuilder()
|
var hostBuilder = TransportSelector.GetWebHostBuilder()
|
||||||
|
|
@ -97,6 +103,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
Assert.Equal(data, buffer);
|
Assert.Equal(data, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wait for the server to complete the loop because of the FIN
|
||||||
|
await serverConnectionCompletedTcs.Task.DefaultTimeout();
|
||||||
|
|
||||||
await host.StopAsync();
|
await host.StopAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue