Small improvement to HttpsConnectionMiddleware (#14764)

- Dispatch using Task.Yield instead of Task.Run. Task.Yield no longer allocates a work item or delegate and doesn't break causality when looking at dumps while Task.Run does.
This commit is contained in:
David Fowler 2019-10-07 09:17:44 -07:00 committed by GitHub
parent 4e79a278e3
commit 677fb870fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -78,13 +78,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https.Internal
_options = options;
_logger = loggerFactory?.CreateLogger<HttpsConnectionMiddleware>();
}
public Task OnConnectionAsync(ConnectionContext context)
public async Task OnConnectionAsync(ConnectionContext context)
{
return Task.Run(() => InnerOnConnectionAsync(context));
}
await Task.Yield();
private async Task InnerOnConnectionAsync(ConnectionContext context)
{
bool certificateRequired;
var feature = new Core.Internal.TlsConnectionFeature();
context.Features.Set<ITlsConnectionFeature>(feature);