From a97f6b3d5069bfded90fb928edc28df0ef9115e8 Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 17 Feb 2016 15:21:11 -0800 Subject: [PATCH] Add IHttpConnectionFeature.ConnectionId. --- .../Http/Connection.cs | 32 ++++----- .../Http/ConnectionContext.cs | 18 +++++ .../Http/Frame.FeatureCollection.cs | 2 + .../Http/Frame.cs | 27 ++----- .../Http/FrameOfT.cs | 11 +-- .../Http/SocketOutput.cs | 4 +- .../Infrastructure/IKestrelTrace.cs | 28 ++++---- .../Infrastructure/KestrelTrace.cs | 72 +++++++++---------- .../KestrelServer.cs | 4 +- .../ServiceContext.cs | 2 +- .../RequestTests.cs | 2 +- .../SocketOutputTests.cs | 14 ++-- .../TestLogger.cs | 6 +- .../TestServer.cs | 4 +- .../TestServiceContext.cs | 4 +- 15 files changed, 113 insertions(+), 117 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Http/Connection.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Http/Connection.cs index 15f57a807..c94789132 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Http/Connection.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Http/Connection.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Globalization; using System.Net; using System.Threading; using Microsoft.AspNetCore.Server.Kestrel.Filter; @@ -24,7 +25,6 @@ public class Connection : ConnectionContext, IConnectionControl private Frame _frame; private ConnectionFilterContext _filterContext; private LibuvStream _libuvStream; - private readonly long _connectionId; private readonly SocketInput _rawSocketInput; private readonly SocketOutput _rawSocketOutput; @@ -32,23 +32,20 @@ public class Connection : ConnectionContext, IConnectionControl private readonly object _stateLock = new object(); private ConnectionState _connectionState; - private IPEndPoint _remoteEndPoint; - private IPEndPoint _localEndPoint; - public Connection(ListenerContext context, UvStreamHandle socket) : base(context) { _socket = socket; ConnectionControl = this; - _connectionId = Interlocked.Increment(ref _lastConnectionId); + ConnectionId = Interlocked.Increment(ref _lastConnectionId).ToString(CultureInfo.InvariantCulture); _rawSocketInput = new SocketInput(Memory2, ThreadPool); - _rawSocketOutput = new SocketOutput(Thread, _socket, Memory2, this, _connectionId, Log, ThreadPool, WriteReqPool); + _rawSocketOutput = new SocketOutput(Thread, _socket, Memory2, this, ConnectionId, Log, ThreadPool, WriteReqPool); } public void Start() { - Log.ConnectionStart(_connectionId); + Log.ConnectionStart(ConnectionId); // Start socket prior to applying the ConnectionFilter _socket.ReadStart(_allocCallback, _readCallback, this); @@ -56,8 +53,8 @@ public void Start() var tcpHandle = _socket as UvTcpHandle; if (tcpHandle != null) { - _remoteEndPoint = tcpHandle.GetPeerIPEndPoint(); - _localEndPoint = tcpHandle.GetSockIPEndPoint(); + RemoteEndPoint = tcpHandle.GetPeerIPEndPoint(); + LocalEndPoint = tcpHandle.GetSockIPEndPoint(); } // Don't initialize _frame until SocketInput and SocketOutput are set to their final values. @@ -78,6 +75,7 @@ public void Start() Connection = _libuvStream, Address = ServerAddress }; + PrepareRequest = _filterContext.PrepareRequest; try { @@ -170,12 +168,12 @@ private void OnRead(UvStreamHandle handle, int status) if (normalRead) { - Log.ConnectionRead(_connectionId, readCount); + Log.ConnectionRead(ConnectionId, readCount); } else { _socket.ReadStop(); - Log.ConnectionReadFin(_connectionId); + Log.ConnectionReadFin(ConnectionId); } Exception error = null; @@ -194,18 +192,18 @@ private void OnRead(UvStreamHandle handle, int status) private Frame CreateFrame() { - return FrameFactory(this, _remoteEndPoint, _localEndPoint, _filterContext?.PrepareRequest); + return FrameFactory(this); } void IConnectionControl.Pause() { - Log.ConnectionPause(_connectionId); + Log.ConnectionPause(ConnectionId); _socket.ReadStop(); } void IConnectionControl.Resume() { - Log.ConnectionResume(_connectionId); + Log.ConnectionResume(ConnectionId); _socket.ReadStart(_allocCallback, _readCallback, this); } @@ -222,7 +220,7 @@ void IConnectionControl.End(ProduceEndType endType) } _connectionState = ConnectionState.Shutdown; - Log.ConnectionWriteFin(_connectionId); + Log.ConnectionWriteFin(ConnectionId); _rawSocketOutput.End(endType); break; case ProduceEndType.ConnectionKeepAlive: @@ -231,7 +229,7 @@ void IConnectionControl.End(ProduceEndType endType) return; } - Log.ConnectionKeepAlive(_connectionId); + Log.ConnectionKeepAlive(ConnectionId); break; case ProduceEndType.SocketDisconnect: if (_connectionState == ConnectionState.Disconnected) @@ -240,7 +238,7 @@ void IConnectionControl.End(ProduceEndType endType) } _connectionState = ConnectionState.Disconnected; - Log.ConnectionDisconnect(_connectionId); + Log.ConnectionDisconnect(ConnectionId); _rawSocketOutput.End(endType); break; } diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Http/ConnectionContext.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Http/ConnectionContext.cs index 3a624d365..bea3e7c7a 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Http/ConnectionContext.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Http/ConnectionContext.cs @@ -1,6 +1,10 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; +using System.Net; +using Microsoft.AspNetCore.Http.Features; + namespace Microsoft.AspNetCore.Server.Kestrel.Http { public class ConnectionContext : ListenerContext @@ -18,10 +22,24 @@ public ConnectionContext(ConnectionContext context) : base(context) SocketInput = context.SocketInput; SocketOutput = context.SocketOutput; ConnectionControl = context.ConnectionControl; + RemoteEndPoint = context.RemoteEndPoint; + LocalEndPoint = context.LocalEndPoint; + ConnectionId = context.ConnectionId; + PrepareRequest = context.PrepareRequest; } public SocketInput SocketInput { get; set; } + public ISocketOutput SocketOutput { get; set; } + public IConnectionControl ConnectionControl { get; set; } + + public IPEndPoint RemoteEndPoint { get; set; } + + public IPEndPoint LocalEndPoint { get; set; } + + public string ConnectionId { get; set; } + + public Action PrepareRequest { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Http/Frame.FeatureCollection.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Http/Frame.FeatureCollection.cs index a1d03fd2b..827398ba0 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Http/Frame.FeatureCollection.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Http/Frame.FeatureCollection.cs @@ -272,6 +272,8 @@ bool IHttpUpgradeFeature.IsUpgradableRequest int IHttpConnectionFeature.LocalPort { get; set; } + string IHttpConnectionFeature.ConnectionId { get; set; } + object IFeatureCollection.this[Type key] { get { return FastFeatureGet(key); } diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Http/Frame.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Http/Frame.cs index 81aa57bb5..6b34db36c 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Http/Frame.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Http/Frame.cs @@ -71,26 +71,11 @@ public abstract partial class Frame : FrameContext, IFrameControl private HttpVersionType _httpVersion; - private readonly IPEndPoint _localEndPoint; - private readonly IPEndPoint _remoteEndPoint; - private readonly Action _prepareRequest; - private readonly string _pathBase; public Frame(ConnectionContext context) - : this(context, remoteEndPoint: null, localEndPoint: null, prepareRequest: null) - { - } - - public Frame(ConnectionContext context, - IPEndPoint remoteEndPoint, - IPEndPoint localEndPoint, - Action prepareRequest) : base(context) { - _remoteEndPoint = remoteEndPoint; - _localEndPoint = localEndPoint; - _prepareRequest = prepareRequest; _pathBase = context.ServerAddress.PathBase; if (ReuseStreams) { @@ -227,13 +212,15 @@ public void Reset() DuplexStream = null; var httpConnectionFeature = this as IHttpConnectionFeature; - httpConnectionFeature.RemoteIpAddress = _remoteEndPoint?.Address; - httpConnectionFeature.RemotePort = _remoteEndPoint?.Port ?? 0; + httpConnectionFeature.RemoteIpAddress = RemoteEndPoint?.Address; + httpConnectionFeature.RemotePort = RemoteEndPoint?.Port ?? 0; + + httpConnectionFeature.LocalIpAddress = LocalEndPoint?.Address; + httpConnectionFeature.LocalPort = LocalEndPoint?.Port ?? 0; - httpConnectionFeature.LocalIpAddress = _localEndPoint?.Address; - httpConnectionFeature.LocalPort = _localEndPoint?.Port ?? 0; + httpConnectionFeature.ConnectionId = ConnectionId; - _prepareRequest?.Invoke(this); + PrepareRequest?.Invoke(this); _manuallySetRequestAbortToken = null; _abortedCts = null; diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Http/FrameOfT.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Http/FrameOfT.cs index 0d9ea1d67..73d13824b 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Http/FrameOfT.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Http/FrameOfT.cs @@ -17,16 +17,7 @@ public class Frame : Frame public Frame(IHttpApplication application, ConnectionContext context) - : this(application, context, remoteEndPoint: null, localEndPoint: null, prepareRequest: null) - { - } - - public Frame(IHttpApplication application, - ConnectionContext context, - IPEndPoint remoteEndPoint, - IPEndPoint localEndPoint, - Action prepareRequest) - : base(context, remoteEndPoint, localEndPoint, prepareRequest) + : base(context) { _application = application; } diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Http/SocketOutput.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Http/SocketOutput.cs index bb39a268a..56214b93a 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Http/SocketOutput.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Http/SocketOutput.cs @@ -26,7 +26,7 @@ public class SocketOutput : ISocketOutput private readonly KestrelThread _thread; private readonly UvStreamHandle _socket; private readonly Connection _connection; - private readonly long _connectionId; + private readonly string _connectionId; private readonly IKestrelTrace _log; private readonly IThreadPool _threadPool; @@ -58,7 +58,7 @@ public SocketOutput( UvStreamHandle socket, MemoryPool2 memory, Connection connection, - long connectionId, + string connectionId, IKestrelTrace log, IThreadPool threadPool, Queue writeReqPool) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/IKestrelTrace.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/IKestrelTrace.cs index 0ed3c6565..6077ec99a 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/IKestrelTrace.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/IKestrelTrace.cs @@ -5,33 +5,33 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Infrastructure { public interface IKestrelTrace : ILogger { - void ConnectionStart(long connectionId); + void ConnectionStart(string connectionId); - void ConnectionStop(long connectionId); + void ConnectionStop(string connectionId); - void ConnectionRead(long connectionId, int count); + void ConnectionRead(string connectionId, int count); - void ConnectionPause(long connectionId); + void ConnectionPause(string connectionId); - void ConnectionResume(long connectionId); + void ConnectionResume(string connectionId); - void ConnectionReadFin(long connectionId); + void ConnectionReadFin(string connectionId); - void ConnectionWriteFin(long connectionId); + void ConnectionWriteFin(string connectionId); - void ConnectionWroteFin(long connectionId, int status); + void ConnectionWroteFin(string connectionId, int status); - void ConnectionKeepAlive(long connectionId); + void ConnectionKeepAlive(string connectionId); - void ConnectionDisconnect(long connectionId); + void ConnectionDisconnect(string connectionId); - void ConnectionWrite(long connectionId, int count); + void ConnectionWrite(string connectionId, int count); - void ConnectionWriteCallback(long connectionId, int status); + void ConnectionWriteCallback(string connectionId, int status); - void ConnectionError(long connectionId, Exception ex); + void ConnectionError(string connectionId, Exception ex); - void ConnectionDisconnectedWrite(long connectionId, int count, Exception ex); + void ConnectionDisconnectedWrite(string connectionId, int count, Exception ex); void ApplicationError(Exception ex); } diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/KestrelTrace.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/KestrelTrace.cs index 9be3819e8..a58a3909e 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/KestrelTrace.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/KestrelTrace.cs @@ -12,37 +12,37 @@ namespace Microsoft.AspNetCore.Server.Kestrel /// public class KestrelTrace : IKestrelTrace { - private static readonly Action _connectionStart; - private static readonly Action _connectionStop; - private static readonly Action _connectionPause; - private static readonly Action _connectionResume; - private static readonly Action _connectionReadFin; - private static readonly Action _connectionWriteFin; - private static readonly Action _connectionWroteFin; - private static readonly Action _connectionKeepAlive; - private static readonly Action _connectionDisconnect; - private static readonly Action _connectionError; - private static readonly Action _connectionDisconnectedWrite; + private static readonly Action _connectionStart; + private static readonly Action _connectionStop; + private static readonly Action _connectionPause; + private static readonly Action _connectionResume; + private static readonly Action _connectionReadFin; + private static readonly Action _connectionWriteFin; + private static readonly Action _connectionWroteFin; + private static readonly Action _connectionKeepAlive; + private static readonly Action _connectionDisconnect; + private static readonly Action _connectionError; + private static readonly Action _connectionDisconnectedWrite; protected readonly ILogger _logger; static KestrelTrace() { - _connectionStart = LoggerMessage.Define(LogLevel.Debug, 1, @"Connection id ""{ConnectionId}"" started."); - _connectionStop = LoggerMessage.Define(LogLevel.Debug, 2, @"Connection id ""{ConnectionId}"" stopped."); + _connectionStart = LoggerMessage.Define(LogLevel.Debug, 1, @"Connection id ""{ConnectionId}"" started."); + _connectionStop = LoggerMessage.Define(LogLevel.Debug, 2, @"Connection id ""{ConnectionId}"" stopped."); // ConnectionRead: Reserved: 3 - _connectionPause = LoggerMessage.Define(LogLevel.Debug, 4, @"Connection id ""{ConnectionId}"" paused."); - _connectionResume = LoggerMessage.Define(LogLevel.Debug, 5, @"Connection id ""{ConnectionId}"" resumed."); - _connectionReadFin = LoggerMessage.Define(LogLevel.Debug, 6, @"Connection id ""{ConnectionId}"" received FIN."); - _connectionWriteFin = LoggerMessage.Define(LogLevel.Debug, 7, @"Connection id ""{ConnectionId}"" sending FIN."); - _connectionWroteFin = LoggerMessage.Define(LogLevel.Debug, 8, @"Connection id ""{ConnectionId}"" sent FIN with status ""{Status}""."); - _connectionKeepAlive = LoggerMessage.Define(LogLevel.Debug, 9, @"Connection id ""{ConnectionId}"" completed keep alive response."); - _connectionDisconnect = LoggerMessage.Define(LogLevel.Debug, 10, @"Connection id ""{ConnectionId}"" disconnected."); + _connectionPause = LoggerMessage.Define(LogLevel.Debug, 4, @"Connection id ""{ConnectionId}"" paused."); + _connectionResume = LoggerMessage.Define(LogLevel.Debug, 5, @"Connection id ""{ConnectionId}"" resumed."); + _connectionReadFin = LoggerMessage.Define(LogLevel.Debug, 6, @"Connection id ""{ConnectionId}"" received FIN."); + _connectionWriteFin = LoggerMessage.Define(LogLevel.Debug, 7, @"Connection id ""{ConnectionId}"" sending FIN."); + _connectionWroteFin = LoggerMessage.Define(LogLevel.Debug, 8, @"Connection id ""{ConnectionId}"" sent FIN with status ""{Status}""."); + _connectionKeepAlive = LoggerMessage.Define(LogLevel.Debug, 9, @"Connection id ""{ConnectionId}"" completed keep alive response."); + _connectionDisconnect = LoggerMessage.Define(LogLevel.Debug, 10, @"Connection id ""{ConnectionId}"" disconnected."); // ConnectionWrite: Reserved: 11 // ConnectionWriteCallback: Reserved: 12 // ApplicationError: Reserved: 13 - LoggerMessage.Define overload not present - _connectionError = LoggerMessage.Define(LogLevel.Information, 14, @"Connection id ""{ConnectionId}"" communication error"); - _connectionDisconnectedWrite = LoggerMessage.Define(LogLevel.Debug, 15, @"Connection id ""{ConnectionId}"" write of ""{count}"" bytes to disconnected client."); + _connectionError = LoggerMessage.Define(LogLevel.Information, 14, @"Connection id ""{ConnectionId}"" communication error"); + _connectionDisconnectedWrite = LoggerMessage.Define(LogLevel.Debug, 15, @"Connection id ""{ConnectionId}"" write of ""{count}"" bytes to disconnected client."); } public KestrelTrace(ILogger logger) @@ -50,64 +50,64 @@ public KestrelTrace(ILogger logger) _logger = logger; } - public virtual void ConnectionStart(long connectionId) + public virtual void ConnectionStart(string connectionId) { _connectionStart(_logger, connectionId, null); } - public virtual void ConnectionStop(long connectionId) + public virtual void ConnectionStop(string connectionId) { _connectionStop(_logger, connectionId, null); } - public virtual void ConnectionRead(long connectionId, int count) + public virtual void ConnectionRead(string connectionId, int count) { // Don't log for now since this could be *too* verbose. // Reserved: Event ID 3 } - public virtual void ConnectionPause(long connectionId) + public virtual void ConnectionPause(string connectionId) { _connectionPause(_logger, connectionId, null); } - public virtual void ConnectionResume(long connectionId) + public virtual void ConnectionResume(string connectionId) { _connectionResume(_logger, connectionId, null); } - public virtual void ConnectionReadFin(long connectionId) + public virtual void ConnectionReadFin(string connectionId) { _connectionReadFin(_logger, connectionId, null); } - public virtual void ConnectionWriteFin(long connectionId) + public virtual void ConnectionWriteFin(string connectionId) { _connectionWriteFin(_logger, connectionId, null); } - public virtual void ConnectionWroteFin(long connectionId, int status) + public virtual void ConnectionWroteFin(string connectionId, int status) { _connectionWroteFin(_logger, connectionId, status, null); } - public virtual void ConnectionKeepAlive(long connectionId) + public virtual void ConnectionKeepAlive(string connectionId) { _connectionKeepAlive(_logger, connectionId, null); } - public virtual void ConnectionDisconnect(long connectionId) + public virtual void ConnectionDisconnect(string connectionId) { _connectionDisconnect(_logger, connectionId, null); } - public virtual void ConnectionWrite(long connectionId, int count) + public virtual void ConnectionWrite(string connectionId, int count) { // Don't log for now since this could be *too* verbose. // Reserved: Event ID 11 } - public virtual void ConnectionWriteCallback(long connectionId, int status) + public virtual void ConnectionWriteCallback(string connectionId, int status) { // Don't log for now since this could be *too* verbose. // Reserved: Event ID 12 @@ -118,12 +118,12 @@ public virtual void ApplicationError(Exception ex) _logger.LogError(13, ex, "An unhandled exception was thrown by the application."); } - public virtual void ConnectionError(long connectionId, Exception ex) + public virtual void ConnectionError(string connectionId, Exception ex) { _connectionError(_logger, connectionId, ex); } - public virtual void ConnectionDisconnectedWrite(long connectionId, int count, Exception ex) + public virtual void ConnectionDisconnectedWrite(string connectionId, int count, Exception ex) { _connectionDisconnectedWrite(_logger, connectionId, count, ex); } diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServer.cs b/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServer.cs index fed5bea66..c0445c5ea 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServer.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServer.cs @@ -58,9 +58,9 @@ public void Start(IHttpApplication application) var trace = new KestrelTrace(_logger); var engine = new KestrelEngine(new ServiceContext { - FrameFactory = (context, remoteEP, localEP, prepareRequest) => + FrameFactory = context => { - return new Frame(application, context, remoteEP, localEP, prepareRequest); + return new Frame(application, context); }, AppLifetime = _applicationLifetime, Log = trace, diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/ServiceContext.cs b/src/Microsoft.AspNetCore.Server.Kestrel/ServiceContext.cs index a299ff946..cf672a43f 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/ServiceContext.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/ServiceContext.cs @@ -35,7 +35,7 @@ public ServiceContext(ServiceContext context) public IThreadPool ThreadPool { get; set; } - public Func, Frame> FrameFactory { get; set; } + public Func FrameFactory { get; set; } public DateHeaderValueManager DateHeaderValueManager { get; set; } diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/RequestTests.cs b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/RequestTests.cs index 3f9b0870d..a6fac125e 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/RequestTests.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/RequestTests.cs @@ -132,7 +132,7 @@ public async Task DoesNotHangOnConnectionCloseRequest() [ConditionalFact] [FrameworkSkipCondition(RuntimeFrameworks.Mono, SkipReason = "Test hangs after execution on Mono.")] - public async Task RequestPathIsNormalized() + public void RequestPathIsNormalized() { var port = PortManager.GetPort(); var config = new ConfigurationBuilder().AddInMemoryCollection( diff --git a/test/Microsoft.AspNetCore.Server.KestrelTests/SocketOutputTests.cs b/test/Microsoft.AspNetCore.Server.KestrelTests/SocketOutputTests.cs index df8edab06..9735e125d 100644 --- a/test/Microsoft.AspNetCore.Server.KestrelTests/SocketOutputTests.cs +++ b/test/Microsoft.AspNetCore.Server.KestrelTests/SocketOutputTests.cs @@ -42,7 +42,7 @@ public void CanWrite1MB() var socket = new MockSocket(kestrelThread.Loop.ThreadId, new TestKestrelTrace()); var trace = new KestrelTrace(new TestKestrelTrace()); var ltp = new LoggingThreadPool(trace); - var socketOutput = new SocketOutput(kestrelThread, socket, memory, null, 0, trace, ltp, new Queue()); + var socketOutput = new SocketOutput(kestrelThread, socket, memory, null, "0", trace, ltp, new Queue()); // I doubt _maxBytesPreCompleted will ever be over a MB. If it is, we should change this test. var bufferSize = 1048576; @@ -89,7 +89,7 @@ public void WritesDontCompleteImmediatelyWhenTooManyBytesAreAlreadyPreCompleted( var socket = new MockSocket(kestrelThread.Loop.ThreadId, new TestKestrelTrace()); var trace = new KestrelTrace(new TestKestrelTrace()); var ltp = new LoggingThreadPool(trace); - var socketOutput = new SocketOutput(kestrelThread, socket, memory, null, 0, trace, ltp, new Queue()); + var socketOutput = new SocketOutput(kestrelThread, socket, memory, null, "0", trace, ltp, new Queue()); var bufferSize = maxBytesPreCompleted; var buffer = new ArraySegment(new byte[bufferSize], 0, bufferSize); @@ -148,7 +148,7 @@ public void WritesDontCompleteImmediatelyWhenTooManyBytesIncludingNonImmediateAr var socket = new MockSocket(kestrelThread.Loop.ThreadId, new TestKestrelTrace()); var trace = new KestrelTrace(new TestKestrelTrace()); var ltp = new LoggingThreadPool(trace); - var socketOutput = new SocketOutput(kestrelThread, socket, memory, null, 0, trace, ltp, new Queue()); + var socketOutput = new SocketOutput(kestrelThread, socket, memory, null, "0", trace, ltp, new Queue()); var bufferSize = maxBytesPreCompleted / 2; var data = new byte[bufferSize]; @@ -212,7 +212,7 @@ public async Task OnlyWritesRequestingCancellationAreErroredOnCancellation() var socket = new MockSocket(kestrelThread.Loop.ThreadId, new TestKestrelTrace()); var trace = new KestrelTrace(new TestKestrelTrace()); var ltp = new LoggingThreadPool(trace); - ISocketOutput socketOutput = new SocketOutput(kestrelThread, socket, memory, new MockConnection(socket), 0, trace, ltp, new Queue()); + ISocketOutput socketOutput = new SocketOutput(kestrelThread, socket, memory, new MockConnection(socket), "0", trace, ltp, new Queue()); var bufferSize = maxBytesPreCompleted; @@ -313,7 +313,7 @@ public async Task FailedWriteCompletesOrCancelsAllPendingTasks() var mockConnection = new MockConnection(socket); mockConnection.RequestAbortedSource = abortedSource; - ISocketOutput socketOutput = new SocketOutput(kestrelThread, socket, memory, mockConnection, 0, trace, ltp, new Queue()); + ISocketOutput socketOutput = new SocketOutput(kestrelThread, socket, memory, mockConnection, "0", trace, ltp, new Queue()); var bufferSize = maxBytesPreCompleted; @@ -387,7 +387,7 @@ public void WritesDontGetCompletedTooQuickly() var socket = new MockSocket(kestrelThread.Loop.ThreadId, new TestKestrelTrace()); var trace = new KestrelTrace(new TestKestrelTrace()); var ltp = new LoggingThreadPool(trace); - var socketOutput = new SocketOutput(kestrelThread, socket, memory, null, 0, trace, ltp, new Queue()); + var socketOutput = new SocketOutput(kestrelThread, socket, memory, null, "0", trace, ltp, new Queue()); var bufferSize = maxBytesPreCompleted; var buffer = new ArraySegment(new byte[bufferSize], 0, bufferSize); @@ -464,7 +464,7 @@ public void ProducingStartAndProducingCompleteCanBeUsedDirectly() var socket = new MockSocket(kestrelThread.Loop.ThreadId, new TestKestrelTrace()); var trace = new KestrelTrace(new TestKestrelTrace()); var ltp = new LoggingThreadPool(trace); - var socketOutput = new SocketOutput(kestrelThread, socket, memory, null, 0, trace, ltp, new Queue()); + var socketOutput = new SocketOutput(kestrelThread, socket, memory, null, "0", trace, ltp, new Queue()); // block 1 var start = socketOutput.ProducingStart(); diff --git a/test/Microsoft.AspNetCore.Server.KestrelTests/TestLogger.cs b/test/Microsoft.AspNetCore.Server.KestrelTests/TestLogger.cs index eead43b30..11076560b 100644 --- a/test/Microsoft.AspNetCore.Server.KestrelTests/TestLogger.cs +++ b/test/Microsoft.AspNetCore.Server.KestrelTests/TestLogger.cs @@ -11,17 +11,17 @@ public TestKestrelTrace() : base(new TestLogger()) } - public override void ConnectionRead(long connectionId, int count) + public override void ConnectionRead(string connectionId, int count) { //_logger.LogDebug(1, @"Connection id ""{ConnectionId}"" recv {count} bytes.", connectionId, count); } - public override void ConnectionWrite(long connectionId, int count) + public override void ConnectionWrite(string connectionId, int count) { //_logger.LogDebug(1, @"Connection id ""{ConnectionId}"" send {count} bytes.", connectionId, count); } - public override void ConnectionWriteCallback(long connectionId, int status) + public override void ConnectionWriteCallback(string connectionId, int status) { //_logger.LogDebug(1, @"Connection id ""{ConnectionId}"" send finished with status {status}.", connectionId, status); } diff --git a/test/Microsoft.AspNetCore.Server.KestrelTests/TestServer.cs b/test/Microsoft.AspNetCore.Server.KestrelTests/TestServer.cs index 1c0ff5dd1..6a84a29fd 100644 --- a/test/Microsoft.AspNetCore.Server.KestrelTests/TestServer.cs +++ b/test/Microsoft.AspNetCore.Server.KestrelTests/TestServer.cs @@ -39,9 +39,9 @@ public TestServer(RequestDelegate app, ServiceContext context, string serverAddr public void Create(RequestDelegate app, ServiceContext context, string serverAddress) { - context.FrameFactory = (connectionContext, remoteEP, localEP, prepareRequest) => + context.FrameFactory = connectionContext => { - return new Frame(new DummyApplication(app), connectionContext, remoteEP, localEP, prepareRequest); + return new Frame(new DummyApplication(app), connectionContext); }; _engine = new KestrelEngine(context); _engine.Start(1); diff --git a/test/Microsoft.AspNetCore.Server.KestrelTests/TestServiceContext.cs b/test/Microsoft.AspNetCore.Server.KestrelTests/TestServiceContext.cs index 4224c776d..22af5bc87 100644 --- a/test/Microsoft.AspNetCore.Server.KestrelTests/TestServiceContext.cs +++ b/test/Microsoft.AspNetCore.Server.KestrelTests/TestServiceContext.cs @@ -29,9 +29,9 @@ public RequestDelegate App set { _app = value; - FrameFactory = (connectionContext, remoteEP, localEP, prepareRequest) => + FrameFactory = connectionContext => { - return new Frame(new DummyApplication(_app), connectionContext, remoteEP, localEP, prepareRequest); + return new Frame(new DummyApplication(_app), connectionContext); }; } }