From 5e190b404fa7b806ffbe50d99971ffac9ee2c1ee Mon Sep 17 00:00:00 2001 From: David Fowler Date: Wed, 4 Apr 2018 13:00:20 -0700 Subject: [PATCH] Remove lazily initialization of the pipes - This fixes race condition --- .../HttpConnectionDispatcher.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Http.Connections/HttpConnectionDispatcher.cs b/src/Microsoft.AspNetCore.Http.Connections/HttpConnectionDispatcher.cs index 9ba8182277..41a6ba002b 100644 --- a/src/Microsoft.AspNetCore.Http.Connections/HttpConnectionDispatcher.cs +++ b/src/Microsoft.AspNetCore.Http.Connections/HttpConnectionDispatcher.cs @@ -381,6 +381,8 @@ namespace Microsoft.AspNetCore.Http.Connections // Establish the connection var connection = _manager.CreateConnection(); + EnsureConnectionStateInternal(connection, options); + // Set the Connection ID on the logging scope so that logs from now on will have the // Connection ID metadata set. logScope.ConnectionId = connection.ConnectionId; @@ -602,8 +604,6 @@ namespace Microsoft.AspNetCore.Http.Connections return null; } - EnsureConnectionStateInternal(connection, options); - return connection; } @@ -630,6 +630,7 @@ namespace Microsoft.AspNetCore.Http.Connections if (StringValues.IsNullOrEmpty(connectionId)) { connection = _manager.CreateConnection(); + EnsureConnectionStateInternal(connection, options); } else if (!_manager.TryGetConnection(connectionId, out connection)) { @@ -639,8 +640,6 @@ namespace Microsoft.AspNetCore.Http.Connections return null; } - EnsureConnectionStateInternal(connection, options); - return connection; }