Add IHttpConnectionFeature.ConnectionId.

This commit is contained in:
Chris R 2016-02-18 10:59:12 -08:00
parent aa48ad2933
commit aef612bdac
14 changed files with 145 additions and 117 deletions

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Filter;
@ -14,18 +13,23 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
{
public class Connection : ConnectionContext, IConnectionControl
{
// Base32 encoding - in ascii sort order for easy text based sorting
private static readonly string _encode32Chars = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
private static readonly Action<UvStreamHandle, int, object> _readCallback =
(handle, status, state) => ReadCallback(handle, status, state);
private static readonly Func<UvStreamHandle, int, object, Libuv.uv_buf_t> _allocCallback =
(handle, suggestedsize, state) => AllocCallback(handle, suggestedsize, state);
private static long _lastConnectionId;
// Seed the _lastConnectionId for this application instance with
// the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001
// for a roughly increasing _requestId over restarts
private static long _lastConnectionId = DateTime.UtcNow.Ticks;
private readonly UvStreamHandle _socket;
private Frame _frame;
private ConnectionFilterContext _filterContext;
private LibuvStream _libuvStream;
private readonly long _connectionId;
private readonly SocketInput _rawSocketInput;
private readonly SocketOutput _rawSocketOutput;
@ -34,19 +38,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
private ConnectionState _connectionState;
private TaskCompletionSource<object> _socketClosedTcs;
private IPEndPoint _remoteEndPoint;
private IPEndPoint _localEndPoint;
public Connection(ListenerContext context, UvStreamHandle socket) : base(context)
{
_socket = socket;
socket.Connection = this;
ConnectionControl = this;
_connectionId = Interlocked.Increment(ref _lastConnectionId);
ConnectionId = GenerateConnectionId(Interlocked.Increment(ref _lastConnectionId));
_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);
}
// Internal for testing
@ -56,7 +57,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
public void Start()
{
Log.ConnectionStart(_connectionId);
Log.ConnectionStart(ConnectionId);
// Start socket prior to applying the ConnectionFilter
_socket.ReadStart(_allocCallback, _readCallback, this);
@ -64,8 +65,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
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.
@ -218,6 +219,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
SocketOutput = _rawSocketOutput;
}
PrepareRequest = _filterContext.PrepareRequest;
_frame = CreateFrame();
_frame.Start();
}
@ -256,12 +259,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
if (normalRead)
{
Log.ConnectionRead(_connectionId, readCount);
Log.ConnectionRead(ConnectionId, readCount);
}
else
{
_socket.ReadStop();
Log.ConnectionReadFin(_connectionId);
Log.ConnectionReadFin(ConnectionId);
}
Exception error = null;
@ -280,18 +283,18 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
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);
}
@ -307,7 +310,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
return;
}
Log.ConnectionKeepAlive(_connectionId);
Log.ConnectionKeepAlive(ConnectionId);
break;
case ProduceEndType.SocketShutdown:
case ProduceEndType.SocketDisconnect:
@ -318,13 +321,40 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
}
_connectionState = ConnectionState.Disconnecting;
Log.ConnectionDisconnect(_connectionId);
Log.ConnectionDisconnect(ConnectionId);
_rawSocketOutput.End(endType);
break;
}
}
}
private static unsafe string GenerateConnectionId(long id)
{
// The following routine is ~310% faster than calling long.ToString() on x64
// and ~600% faster than calling long.ToString() on x86 in tight loops of 1 million+ iterations
// See: https://github.com/aspnet/Hosting/pull/385
// stackalloc to allocate array on stack rather than heap
char* charBuffer = stackalloc char[13];
charBuffer[0] = _encode32Chars[(int)(id >> 60) & 31];
charBuffer[1] = _encode32Chars[(int)(id >> 55) & 31];
charBuffer[2] = _encode32Chars[(int)(id >> 50) & 31];
charBuffer[3] = _encode32Chars[(int)(id >> 45) & 31];
charBuffer[4] = _encode32Chars[(int)(id >> 40) & 31];
charBuffer[5] = _encode32Chars[(int)(id >> 35) & 31];
charBuffer[6] = _encode32Chars[(int)(id >> 30) & 31];
charBuffer[7] = _encode32Chars[(int)(id >> 25) & 31];
charBuffer[8] = _encode32Chars[(int)(id >> 20) & 31];
charBuffer[9] = _encode32Chars[(int)(id >> 15) & 31];
charBuffer[10] = _encode32Chars[(int)(id >> 10) & 31];
charBuffer[11] = _encode32Chars[(int)(id >> 5) & 31];
charBuffer[12] = _encode32Chars[(int)id & 31];
// string ctor overload that takes char*
return new string(charBuffer, 0, 13);
}
private enum ConnectionState
{
CreatingFrame,

View File

@ -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 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
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<IFeatureCollection> PrepareRequest { get; set; }
}
}

View File

@ -272,6 +272,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
int IHttpConnectionFeature.LocalPort { get; set; }
string IHttpConnectionFeature.ConnectionId { get; set; }
object IFeatureCollection.this[Type key]
{
get { return FastFeatureGet(key); }

View File

@ -67,26 +67,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
private HttpVersionType _httpVersion;
private readonly IPEndPoint _localEndPoint;
private readonly IPEndPoint _remoteEndPoint;
private readonly Action<IFeatureCollection> _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<IFeatureCollection> prepareRequest)
: base(context)
{
_remoteEndPoint = remoteEndPoint;
_localEndPoint = localEndPoint;
_prepareRequest = prepareRequest;
_pathBase = context.ServerAddress.PathBase;
FrameControl = this;
@ -249,13 +234,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
ReasonPhrase = 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;
_prepareRequest?.Invoke(this);
httpConnectionFeature.ConnectionId = ConnectionId;
PrepareRequest?.Invoke(this);
_manuallySetRequestAbortToken = null;
_abortedCts = null;

View File

@ -17,16 +17,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
public Frame(IHttpApplication<TContext> application,
ConnectionContext context)
: this(application, context, remoteEndPoint: null, localEndPoint: null, prepareRequest: null)
{
}
public Frame(IHttpApplication<TContext> application,
ConnectionContext context,
IPEndPoint remoteEndPoint,
IPEndPoint localEndPoint,
Action<IFeatureCollection> prepareRequest)
: base(context, remoteEndPoint, localEndPoint, prepareRequest)
: base(context)
{
_application = application;
}

View File

@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
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 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
UvStreamHandle socket,
MemoryPool2 memory,
Connection connection,
long connectionId,
string connectionId,
IKestrelTrace log,
IThreadPool threadPool,
Queue<UvWriteReq> writeReqPool)

View File

@ -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 NotAllConnectionsClosedGracefully();

View File

@ -12,38 +12,38 @@ namespace Microsoft.AspNetCore.Server.Kestrel
/// </summary>
public class KestrelTrace : IKestrelTrace
{
private static readonly Action<ILogger, long, Exception> _connectionStart;
private static readonly Action<ILogger, long, Exception> _connectionStop;
private static readonly Action<ILogger, long, Exception> _connectionPause;
private static readonly Action<ILogger, long, Exception> _connectionResume;
private static readonly Action<ILogger, long, Exception> _connectionReadFin;
private static readonly Action<ILogger, long, Exception> _connectionWriteFin;
private static readonly Action<ILogger, long, int, Exception> _connectionWroteFin;
private static readonly Action<ILogger, long, Exception> _connectionKeepAlive;
private static readonly Action<ILogger, long, Exception> _connectionDisconnect;
private static readonly Action<ILogger, long, Exception> _connectionError;
private static readonly Action<ILogger, long, int, Exception> _connectionDisconnectedWrite;
private static readonly Action<ILogger, string, Exception> _connectionStart;
private static readonly Action<ILogger, string, Exception> _connectionStop;
private static readonly Action<ILogger, string, Exception> _connectionPause;
private static readonly Action<ILogger, string, Exception> _connectionResume;
private static readonly Action<ILogger, string, Exception> _connectionReadFin;
private static readonly Action<ILogger, string, Exception> _connectionWriteFin;
private static readonly Action<ILogger, string, int, Exception> _connectionWroteFin;
private static readonly Action<ILogger, string, Exception> _connectionKeepAlive;
private static readonly Action<ILogger, string, Exception> _connectionDisconnect;
private static readonly Action<ILogger, string, Exception> _connectionError;
private static readonly Action<ILogger, string, int, Exception> _connectionDisconnectedWrite;
private static readonly Action<ILogger, Exception> _notAllConnectionsClosedGracefully;
protected readonly ILogger _logger;
static KestrelTrace()
{
_connectionStart = LoggerMessage.Define<long>(LogLevel.Debug, 1, @"Connection id ""{ConnectionId}"" started.");
_connectionStop = LoggerMessage.Define<long>(LogLevel.Debug, 2, @"Connection id ""{ConnectionId}"" stopped.");
_connectionStart = LoggerMessage.Define<string>(LogLevel.Debug, 1, @"Connection id ""{ConnectionId}"" started.");
_connectionStop = LoggerMessage.Define<string>(LogLevel.Debug, 2, @"Connection id ""{ConnectionId}"" stopped.");
// ConnectionRead: Reserved: 3
_connectionPause = LoggerMessage.Define<long>(LogLevel.Debug, 4, @"Connection id ""{ConnectionId}"" paused.");
_connectionResume = LoggerMessage.Define<long>(LogLevel.Debug, 5, @"Connection id ""{ConnectionId}"" resumed.");
_connectionReadFin = LoggerMessage.Define<long>(LogLevel.Debug, 6, @"Connection id ""{ConnectionId}"" received FIN.");
_connectionWriteFin = LoggerMessage.Define<long>(LogLevel.Debug, 7, @"Connection id ""{ConnectionId}"" sending FIN.");
_connectionWroteFin = LoggerMessage.Define<long, int>(LogLevel.Debug, 8, @"Connection id ""{ConnectionId}"" sent FIN with status ""{Status}"".");
_connectionKeepAlive = LoggerMessage.Define<long>(LogLevel.Debug, 9, @"Connection id ""{ConnectionId}"" completed keep alive response.");
_connectionDisconnect = LoggerMessage.Define<long>(LogLevel.Debug, 10, @"Connection id ""{ConnectionId}"" disconnecting.");
_connectionPause = LoggerMessage.Define<string>(LogLevel.Debug, 4, @"Connection id ""{ConnectionId}"" paused.");
_connectionResume = LoggerMessage.Define<string>(LogLevel.Debug, 5, @"Connection id ""{ConnectionId}"" resumed.");
_connectionReadFin = LoggerMessage.Define<string>(LogLevel.Debug, 6, @"Connection id ""{ConnectionId}"" received FIN.");
_connectionWriteFin = LoggerMessage.Define<string>(LogLevel.Debug, 7, @"Connection id ""{ConnectionId}"" sending FIN.");
_connectionWroteFin = LoggerMessage.Define<string, int>(LogLevel.Debug, 8, @"Connection id ""{ConnectionId}"" sent FIN with status ""{Status}"".");
_connectionKeepAlive = LoggerMessage.Define<string>(LogLevel.Debug, 9, @"Connection id ""{ConnectionId}"" completed keep alive response.");
_connectionDisconnect = LoggerMessage.Define<string>(LogLevel.Debug, 10, @"Connection id ""{ConnectionId}"" disconnecting.");
// ConnectionWrite: Reserved: 11
// ConnectionWriteCallback: Reserved: 12
// ApplicationError: Reserved: 13 - LoggerMessage.Define overload not present
_connectionError = LoggerMessage.Define<long>(LogLevel.Information, 14, @"Connection id ""{ConnectionId}"" communication error");
_connectionDisconnectedWrite = LoggerMessage.Define<long, int>(LogLevel.Debug, 15, @"Connection id ""{ConnectionId}"" write of ""{count}"" bytes to disconnected client.");
_connectionError = LoggerMessage.Define<string>(LogLevel.Information, 14, @"Connection id ""{ConnectionId}"" communication error");
_connectionDisconnectedWrite = LoggerMessage.Define<string, int>(LogLevel.Debug, 15, @"Connection id ""{ConnectionId}"" write of ""{count}"" bytes to disconnected client.");
_notAllConnectionsClosedGracefully = LoggerMessage.Define(LogLevel.Debug, 16, "Some connections failed to close gracefully during server shutdown.");
}
@ -52,64 +52,64 @@ namespace Microsoft.AspNetCore.Server.Kestrel
_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
@ -120,12 +120,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel
_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);
}

View File

@ -59,9 +59,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel
var trace = new KestrelTrace(_logger);
var engine = new KestrelEngine(new ServiceContext
{
FrameFactory = (context, remoteEP, localEP, prepareRequest) =>
FrameFactory = context =>
{
return new Frame<TContext>(application, context, remoteEP, localEP, prepareRequest);
return new Frame<TContext>(application, context);
},
AppLifetime = _applicationLifetime,
Log = trace,

View File

@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel
public IThreadPool ThreadPool { get; set; }
public Func<ConnectionContext, IPEndPoint, IPEndPoint, Action<IFeatureCollection>, Frame> FrameFactory { get; set; }
public Func<ConnectionContext, Frame> FrameFactory { get; set; }
public DateHeaderValueManager DateHeaderValueManager { get; set; }

View File

@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
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, new MockConnection(), 0, trace, ltp, new Queue<UvWriteReq>());
var socketOutput = new SocketOutput(kestrelThread, socket, memory, new MockConnection(), "0", trace, ltp, new Queue<UvWriteReq>());
// I doubt _maxBytesPreCompleted will ever be over a MB. If it is, we should change this test.
var bufferSize = 1048576;
@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
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, new MockConnection(), 0, trace, ltp, new Queue<UvWriteReq>());
var socketOutput = new SocketOutput(kestrelThread, socket, memory, new MockConnection(), "0", trace, ltp, new Queue<UvWriteReq>());
var bufferSize = maxBytesPreCompleted;
var buffer = new ArraySegment<byte>(new byte[bufferSize], 0, bufferSize);
@ -161,7 +161,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
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, new MockConnection(), 0, trace, ltp, new Queue<UvWriteReq>());
var socketOutput = new SocketOutput(kestrelThread, socket, memory, new MockConnection(), "0", trace, ltp, new Queue<UvWriteReq>());
var bufferSize = maxBytesPreCompleted / 2;
var data = new byte[bufferSize];
@ -237,7 +237,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
using (var mockConnection = new MockConnection())
{
ISocketOutput socketOutput = new SocketOutput(kestrelThread, socket, memory, mockConnection, 0, trace, ltp, new Queue<UvWriteReq>());
ISocketOutput socketOutput = new SocketOutput(kestrelThread, socket, memory, mockConnection, "0", trace, ltp, new Queue<UvWriteReq>());
var bufferSize = maxBytesPreCompleted;
@ -348,7 +348,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
using (var mockConnection = new MockConnection())
{
var abortedSource = mockConnection.RequestAbortedSource;
ISocketOutput socketOutput = new SocketOutput(kestrelThread, socket, memory, mockConnection, 0, trace, ltp, new Queue<UvWriteReq>());
ISocketOutput socketOutput = new SocketOutput(kestrelThread, socket, memory, mockConnection, "0", trace, ltp, new Queue<UvWriteReq>());
var bufferSize = maxBytesPreCompleted;
@ -432,7 +432,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
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, new MockConnection(), 0, trace, ltp, new Queue<UvWriteReq>());
var socketOutput = new SocketOutput(kestrelThread, socket, memory, new MockConnection(), "0", trace, ltp, new Queue<UvWriteReq>());
var bufferSize = maxBytesPreCompleted;
var buffer = new ArraySegment<byte>(new byte[bufferSize], 0, bufferSize);
@ -518,7 +518,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
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, new MockConnection(), 0, trace, ltp, new Queue<UvWriteReq>());
var socketOutput = new SocketOutput(kestrelThread, socket, memory, new MockConnection(), "0", trace, ltp, new Queue<UvWriteReq>());
// block 1
var start = socketOutput.ProducingStart();

View File

@ -11,17 +11,17 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
}
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);
}

View File

@ -39,9 +39,9 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
public void Create(RequestDelegate app, ServiceContext context, string serverAddress)
{
context.FrameFactory = (connectionContext, remoteEP, localEP, prepareRequest) =>
context.FrameFactory = connectionContext =>
{
return new Frame<HttpContext>(new DummyApplication(app), connectionContext, remoteEP, localEP, prepareRequest);
return new Frame<HttpContext>(new DummyApplication(app), connectionContext);
};
_engine = new KestrelEngine(context);
_engine.Start(1);

View File

@ -44,9 +44,9 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
set
{
_app = value;
FrameFactory = (connectionContext, remoteEP, localEP, prepareRequest) =>
FrameFactory = connectionContext =>
{
return new Frame<HttpContext>(new DummyApplication(_app), connectionContext, remoteEP, localEP, prepareRequest);
return new Frame<HttpContext>(new DummyApplication(_app), connectionContext);
};
}
}