Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
Expand Down Expand Up @@ -56,14 +57,10 @@ public async Task CriticalErrorLoggedIfApplicationDoesntComplete()
},
testContext))
{
using (var connection = server.CreateConnection())
{
await connection.SendEmptyGet();

Assert.True(await appStartedWh.WaitAsync(TestConstants.DefaultTimeout));

// Close connection without waiting for a response
}
// Create the connection in a separate non-inlined method so that the connection
// and any locals it references aren't kept rooted on this method's stack frame,
// which would prevent HttpConnection from being garbage collected.
await CreateConnectionAndSendRequest(server, appStartedWh);

var logWaitAttempts = 0;

Expand All @@ -77,6 +74,19 @@ public async Task CriticalErrorLoggedIfApplicationDoesntComplete()
}
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static async Task CreateConnectionAndSendRequest(TestServer server, SemaphoreSlim appStartedWh)
{
using (var connection = server.CreateConnection())
{
await connection.SendEmptyGet();

Assert.True(await appStartedWh.WaitAsync(TestConstants.DefaultTimeout));

// Close connection without waiting for a response
}
}

private class CallbackLoggerProvider : ILoggerProvider
{
private readonly Action<EventId> _logAction;
Expand Down
Loading