From b612da4e6cb78ca85cd6d12627037705b467e146 Mon Sep 17 00:00:00 2001 From: Justin Van Patten Date: Sun, 12 Mar 2017 12:20:41 -0700 Subject: [PATCH] Avoid an unnecessary closure allocation in ListenerSecondary (#1485) The tcs is being passed as the state, so use it from the state instead of closing over it. --- .../Internal/Http/ListenerSecondary.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/ListenerSecondary.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/ListenerSecondary.cs index 41de1df45c..331e1bc4f3 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/ListenerSecondary.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/ListenerSecondary.cs @@ -109,13 +109,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http { req.Dispose(); + var innerTcs = (TaskCompletionSource)state; if (ex != null) { - tcs.SetException(ex); + innerTcs.SetException(ex); } else { - tcs.SetResult(0); + innerTcs.SetResult(0); } }, tcs);