diff --git a/benchmarks/Kestrel.Performance/Http1ConnectionParsingOverheadBenchmark.cs b/benchmarks/Kestrel.Performance/Http1ConnectionParsingOverheadBenchmark.cs index 42e4cba170..5b2af1d52a 100644 --- a/benchmarks/Kestrel.Performance/Http1ConnectionParsingOverheadBenchmark.cs +++ b/benchmarks/Kestrel.Performance/Http1ConnectionParsingOverheadBenchmark.cs @@ -23,8 +23,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance [IterationSetup] public void Setup() { - var bufferPool = new MemoryPool(); - var pair = PipeFactory.CreateConnectionPair(bufferPool); + var memoryPool = new MemoryPool(); + var pair = PipeFactory.CreateConnectionPair(memoryPool); var serviceContext = new ServiceContext { @@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), - BufferPool = bufferPool, + MemoryPool = memoryPool, TimeoutControl = new MockTimeoutControl(), Application = pair.Application, Transport = pair.Transport diff --git a/benchmarks/Kestrel.Performance/Http1WritingBenchmark.cs b/benchmarks/Kestrel.Performance/Http1WritingBenchmark.cs index 717009affa..fcc3f86bc4 100644 --- a/benchmarks/Kestrel.Performance/Http1WritingBenchmark.cs +++ b/benchmarks/Kestrel.Performance/Http1WritingBenchmark.cs @@ -111,7 +111,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), - BufferPool = memoryPool, + MemoryPool = memoryPool, Application = pair.Application, Transport = pair.Transport }); diff --git a/benchmarks/Kestrel.Performance/HttpProtocolFeatureCollection.cs b/benchmarks/Kestrel.Performance/HttpProtocolFeatureCollection.cs index b9cc8b27c4..b5ebc8531e 100644 --- a/benchmarks/Kestrel.Performance/HttpProtocolFeatureCollection.cs +++ b/benchmarks/Kestrel.Performance/HttpProtocolFeatureCollection.cs @@ -78,8 +78,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance public HttpProtocolFeatureCollection() { - var bufferPool = new MemoryPool(); - var pair = PipeFactory.CreateConnectionPair(bufferPool); + var memoryPool = new MemoryPool(); + var pair = PipeFactory.CreateConnectionPair(memoryPool); var serviceContext = new ServiceContext { @@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), - BufferPool = bufferPool, + MemoryPool = memoryPool, Application = pair.Application, Transport = pair.Transport }); diff --git a/benchmarks/Kestrel.Performance/PipeThroughputBenchmark.cs b/benchmarks/Kestrel.Performance/PipeThroughputBenchmark.cs index 973a63708d..92b04887f3 100644 --- a/benchmarks/Kestrel.Performance/PipeThroughputBenchmark.cs +++ b/benchmarks/Kestrel.Performance/PipeThroughputBenchmark.cs @@ -15,13 +15,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance private const int InnerLoopCount = 512; private IPipe _pipe; - private BufferPool _bufferPool; + private MemoryPool _memoryPool; [IterationSetup] public void Setup() { - _bufferPool = new MemoryPool(); - _pipe = new Pipe(new PipeOptions(_bufferPool)); + _memoryPool = new MemoryPool(); + _pipe = new Pipe(new PipeOptions(_memoryPool)); } [Benchmark(OperationsPerInvoke = InnerLoopCount)] diff --git a/benchmarks/Kestrel.Performance/RequestParsingBenchmark.cs b/benchmarks/Kestrel.Performance/RequestParsingBenchmark.cs index 52b0bdca68..c7b74bf7d5 100644 --- a/benchmarks/Kestrel.Performance/RequestParsingBenchmark.cs +++ b/benchmarks/Kestrel.Performance/RequestParsingBenchmark.cs @@ -22,8 +22,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance [IterationSetup] public void Setup() { - var bufferPool = new MemoryPool(); - var pair = PipeFactory.CreateConnectionPair(bufferPool); + var memoryPool = new MemoryPool(); + var pair = PipeFactory.CreateConnectionPair(memoryPool); var serviceContext = new ServiceContext { @@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), - BufferPool = bufferPool, + MemoryPool = memoryPool, Application = pair.Application, Transport = pair.Transport, TimeoutControl = new MockTimeoutControl() @@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance http1Connection.Reset(); Http1Connection = http1Connection; - Pipe = new Pipe(new PipeOptions(bufferPool)); + Pipe = new Pipe(new PipeOptions(memoryPool)); } [Benchmark(Baseline = true, OperationsPerInvoke = RequestParsingData.InnerLoopCount)] diff --git a/benchmarks/Kestrel.Performance/ResponseHeaderCollectionBenchmark.cs b/benchmarks/Kestrel.Performance/ResponseHeaderCollectionBenchmark.cs index 664567cd88..1e49ec53f2 100644 --- a/benchmarks/Kestrel.Performance/ResponseHeaderCollectionBenchmark.cs +++ b/benchmarks/Kestrel.Performance/ResponseHeaderCollectionBenchmark.cs @@ -171,8 +171,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance [IterationSetup] public void Setup() { - var bufferPool = new MemoryPool(); - var pair = PipeFactory.CreateConnectionPair(bufferPool); + var memoryPool = new MemoryPool(); + var pair = PipeFactory.CreateConnectionPair(memoryPool); var serviceContext = new ServiceContext { @@ -186,7 +186,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), - BufferPool = bufferPool, + MemoryPool = memoryPool, Application = pair.Application, Transport = pair.Transport }); diff --git a/benchmarks/Kestrel.Performance/ResponseHeadersWritingBenchmark.cs b/benchmarks/Kestrel.Performance/ResponseHeadersWritingBenchmark.cs index e56c7112e5..024fd1ae1c 100644 --- a/benchmarks/Kestrel.Performance/ResponseHeadersWritingBenchmark.cs +++ b/benchmarks/Kestrel.Performance/ResponseHeadersWritingBenchmark.cs @@ -111,8 +111,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance [IterationSetup] public void Setup() { - var bufferPool = new MemoryPool(); - var pair = PipeFactory.CreateConnectionPair(bufferPool); + var memoryPool = new MemoryPool(); + var pair = PipeFactory.CreateConnectionPair(memoryPool); var serviceContext = new ServiceContext { @@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), - BufferPool = bufferPool, + MemoryPool = memoryPool, TimeoutControl = new MockTimeoutControl(), Application = pair.Application, Transport = pair.Transport diff --git a/build/dependencies.props b/build/dependencies.props index 5deb3e804b..0ed82b9623 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,7 +5,7 @@ 0.10.9 - 2.1.0-preview1-15618 + 2.1.0-preview1-15620 1.10.0 2.1.0-preview1-27773 2.1.0-preview1-27773 @@ -22,20 +22,20 @@ 2.1.0-preview1-27773 2.1.0-preview1-27773 2.0.0 - 2.1.0-preview1-25915-01 + 2.1.0-preview1-26008-01 2.1.0-preview1-27773 15.3.0 4.7.49 10.0.1 - 4.5.0-preview1-25914-04 - 0.1.0-alpha-002 - 0.1.0-alpha-002 - 4.5.0-preview1-25914-04 - 4.5.0-preview1-25914-04 - 4.5.0-preview1-25914-04 - 4.5.0-preview1-25914-04 - 0.1.0-alpha-002 - 4.5.0-preview2-25707-02 + 4.5.0-preview1-26006-06 + 0.1.0-e171206-2 + 0.1.0-e171206-2 + 4.5.0-preview1-26006-06 + 4.5.0-preview1-26006-06 + 4.5.0-preview1-26006-06 + 4.5.0-preview1-26006-06 + 0.1.0-e171206-2 + 4.5.0-preview1-26006-06 0.8.0 2.3.1 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e7cce93009..fe4a961da3 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15618 -commithash:00ce1383114015fe89b221146036e59e6bc11219 +version:2.1.0-preview1-15620 +commithash:6432b49a2c00310416df39b6fe548ef4af9c6011 diff --git a/src/Kestrel.Core/Internal/ConnectionHandler.cs b/src/Kestrel.Core/Internal/ConnectionHandler.cs index fd9dc68746..ee49a5b239 100644 --- a/src/Kestrel.Core/Internal/ConnectionHandler.cs +++ b/src/Kestrel.Core/Internal/ConnectionHandler.cs @@ -36,8 +36,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal // REVIEW: Unfortunately, we still need to use the service context to create the pipes since the settings // for the scheduler and limits are specified here - var inputOptions = GetInputPipeOptions(_serviceContext, connectionContext.BufferPool, transportFeature.InputWriterScheduler); - var outputOptions = GetOutputPipeOptions(_serviceContext, connectionContext.BufferPool, transportFeature.OutputReaderScheduler); + var inputOptions = GetInputPipeOptions(_serviceContext, connectionContext.MemoryPool, transportFeature.InputWriterScheduler); + var outputOptions = GetOutputPipeOptions(_serviceContext, connectionContext.MemoryPool, transportFeature.OutputReaderScheduler); var pair = PipeFactory.CreateConnectionPair(inputOptions, outputOptions); @@ -83,18 +83,18 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal } // Internal for testing - internal static PipeOptions GetInputPipeOptions(ServiceContext serviceContext, BufferPool bufferPool, IScheduler writerScheduler) => new PipeOptions + internal static PipeOptions GetInputPipeOptions(ServiceContext serviceContext, MemoryPool memoryPool, IScheduler writerScheduler) => new PipeOptions ( - bufferPool: bufferPool, + pool: memoryPool, readerScheduler: serviceContext.ThreadPool, writerScheduler: writerScheduler, maximumSizeHigh: serviceContext.ServerOptions.Limits.MaxRequestBufferSize ?? 0, maximumSizeLow: serviceContext.ServerOptions.Limits.MaxRequestBufferSize ?? 0 ); - internal static PipeOptions GetOutputPipeOptions(ServiceContext serviceContext, BufferPool bufferPool, IScheduler readerScheduler) => new PipeOptions + internal static PipeOptions GetOutputPipeOptions(ServiceContext serviceContext, MemoryPool memoryPool, IScheduler readerScheduler) => new PipeOptions ( - bufferPool: bufferPool, + pool: memoryPool, readerScheduler: readerScheduler, writerScheduler: serviceContext.ThreadPool, maximumSizeHigh: GetOutputResponseBufferSize(serviceContext), diff --git a/src/Kestrel.Core/Internal/Http/Http1ConnectionContext.cs b/src/Kestrel.Core/Internal/Http/Http1ConnectionContext.cs index de529ea372..b30be13924 100644 --- a/src/Kestrel.Core/Internal/Http/Http1ConnectionContext.cs +++ b/src/Kestrel.Core/Internal/Http/Http1ConnectionContext.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http public string ConnectionId { get; set; } public ServiceContext ServiceContext { get; set; } public IFeatureCollection ConnectionFeatures { get; set; } - public BufferPool BufferPool { get; set; } + public MemoryPool MemoryPool { get; set; } public IPEndPoint RemoteEndPoint { get; set; } public IPEndPoint LocalEndPoint { get; set; } public ITimeoutControl TimeoutControl { get; set; } diff --git a/src/Kestrel.Core/Internal/Http/HttpProtocol.cs b/src/Kestrel.Core/Internal/Http/HttpProtocol.cs index dacd5313f4..fca679dd23 100644 --- a/src/Kestrel.Core/Internal/Http/HttpProtocol.cs +++ b/src/Kestrel.Core/Internal/Http/HttpProtocol.cs @@ -1300,7 +1300,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http private Pipe CreateRequestBodyPipe() => new Pipe(new PipeOptions ( - bufferPool: _context.BufferPool, + pool: _context.MemoryPool, readerScheduler: ServiceContext.ThreadPool, writerScheduler: InlineScheduler.Default, maximumSizeHigh: 1, diff --git a/src/Kestrel.Core/Internal/Http/IHttpProtocolContext.cs b/src/Kestrel.Core/Internal/Http/IHttpProtocolContext.cs index 44abe5160f..392dcf1833 100644 --- a/src/Kestrel.Core/Internal/Http/IHttpProtocolContext.cs +++ b/src/Kestrel.Core/Internal/Http/IHttpProtocolContext.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http string ConnectionId { get; set; } ServiceContext ServiceContext { get; set; } IFeatureCollection ConnectionFeatures { get; set; } - BufferPool BufferPool { get; set; } + MemoryPool MemoryPool { get; set; } IPEndPoint RemoteEndPoint { get; set; } IPEndPoint LocalEndPoint { get; set; } } diff --git a/src/Kestrel.Core/Internal/Http2/Http2Connection.cs b/src/Kestrel.Core/Internal/Http2/Http2Connection.cs index 9d6ac80794..db71ff63c9 100644 --- a/src/Kestrel.Core/Internal/Http2/Http2Connection.cs +++ b/src/Kestrel.Core/Internal/Http2/Http2Connection.cs @@ -398,7 +398,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2 StreamId = _incomingFrame.StreamId, ServiceContext = _context.ServiceContext, ConnectionFeatures = _context.ConnectionFeatures, - BufferPool = _context.BufferPool, + MemoryPool = _context.MemoryPool, LocalEndPoint = _context.LocalEndPoint, RemoteEndPoint = _context.RemoteEndPoint, StreamLifetimeHandler = this, diff --git a/src/Kestrel.Core/Internal/Http2/Http2ConnectionContext.cs b/src/Kestrel.Core/Internal/Http2/Http2ConnectionContext.cs index c4766a7b15..929bef9f92 100644 --- a/src/Kestrel.Core/Internal/Http2/Http2ConnectionContext.cs +++ b/src/Kestrel.Core/Internal/Http2/Http2ConnectionContext.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2 public string ConnectionId { get; set; } public ServiceContext ServiceContext { get; set; } public IFeatureCollection ConnectionFeatures { get; set; } - public BufferPool BufferPool { get; set; } + public MemoryPool MemoryPool { get; set; } public IPEndPoint LocalEndPoint { get; set; } public IPEndPoint RemoteEndPoint { get; set; } diff --git a/src/Kestrel.Core/Internal/Http2/Http2StreamContext.cs b/src/Kestrel.Core/Internal/Http2/Http2StreamContext.cs index 6bc9fc8b82..247e1764a7 100644 --- a/src/Kestrel.Core/Internal/Http2/Http2StreamContext.cs +++ b/src/Kestrel.Core/Internal/Http2/Http2StreamContext.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2 public int StreamId { get; set; } public ServiceContext ServiceContext { get; set; } public IFeatureCollection ConnectionFeatures { get; set; } - public BufferPool BufferPool { get; set; } + public MemoryPool MemoryPool { get; set; } public IPEndPoint RemoteEndPoint { get; set; } public IPEndPoint LocalEndPoint { get; set; } public IHttp2StreamLifetimeHandler StreamLifetimeHandler { get; set; } diff --git a/src/Kestrel.Core/Internal/HttpConnection.cs b/src/Kestrel.Core/Internal/HttpConnection.cs index 81bf33f2dc..44f0fcbd1a 100644 --- a/src/Kestrel.Core/Internal/HttpConnection.cs +++ b/src/Kestrel.Core/Internal/HttpConnection.cs @@ -66,12 +66,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal public IPEndPoint LocalEndPoint => _context.LocalEndPoint; public IPEndPoint RemoteEndPoint => _context.RemoteEndPoint; - private BufferPool BufferPool => _context.BufferPool; + private MemoryPool MemoryPool => _context.MemoryPool; // Internal for testing internal PipeOptions AdaptedInputPipeOptions => new PipeOptions ( - bufferPool: BufferPool, + pool: MemoryPool, readerScheduler: _context.ServiceContext.ThreadPool, writerScheduler: InlineScheduler.Default, maximumSizeHigh: _context.ServiceContext.ServerOptions.Limits.MaxRequestBufferSize ?? 0, @@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal internal PipeOptions AdaptedOutputPipeOptions => new PipeOptions ( - bufferPool: BufferPool, + pool: MemoryPool, readerScheduler: InlineScheduler.Default, writerScheduler: InlineScheduler.Default, maximumSizeHigh: _context.ServiceContext.ServerOptions.Limits.MaxResponseBufferSize ?? 0, @@ -203,7 +203,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal { ConnectionId = _context.ConnectionId, ConnectionFeatures = _context.ConnectionFeatures, - BufferPool = BufferPool, + MemoryPool = MemoryPool, LocalEndPoint = LocalEndPoint, RemoteEndPoint = RemoteEndPoint, ServiceContext = _context.ServiceContext, @@ -220,7 +220,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal ConnectionId = _context.ConnectionId, ServiceContext = _context.ServiceContext, ConnectionFeatures = _context.ConnectionFeatures, - BufferPool = BufferPool, + MemoryPool = MemoryPool, LocalEndPoint = LocalEndPoint, RemoteEndPoint = RemoteEndPoint, Application = application, diff --git a/src/Kestrel.Core/Internal/HttpConnectionContext.cs b/src/Kestrel.Core/Internal/HttpConnectionContext.cs index c2862b170b..dcd5563e79 100644 --- a/src/Kestrel.Core/Internal/HttpConnectionContext.cs +++ b/src/Kestrel.Core/Internal/HttpConnectionContext.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal public ServiceContext ServiceContext { get; set; } public IFeatureCollection ConnectionFeatures { get; set; } public IList ConnectionAdapters { get; set; } - public BufferPool BufferPool { get; set; } + public MemoryPool MemoryPool { get; set; } public IPEndPoint LocalEndPoint { get; set; } public IPEndPoint RemoteEndPoint { get; set; } public IPipeConnection Transport { get; set; } diff --git a/src/Kestrel.Core/Internal/HttpConnectionMiddleware.cs b/src/Kestrel.Core/Internal/HttpConnectionMiddleware.cs index e6686cfd7c..8018438fa4 100644 --- a/src/Kestrel.Core/Internal/HttpConnectionMiddleware.cs +++ b/src/Kestrel.Core/Internal/HttpConnectionMiddleware.cs @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal Protocols = _protocols, ServiceContext = _serviceContext, ConnectionFeatures = connectionContext.Features, - BufferPool = connectionContext.BufferPool, + MemoryPool = connectionContext.MemoryPool, ConnectionAdapters = _connectionAdapters, Transport = connectionContext.Transport, Application = transportFeature.Application diff --git a/src/Kestrel.Transport.Abstractions/Internal/TransportConnection.Features.cs b/src/Kestrel.Transport.Abstractions/Internal/TransportConnection.Features.cs index 7da585aeec..5af87f3293 100644 --- a/src/Kestrel.Transport.Abstractions/Internal/TransportConnection.Features.cs +++ b/src/Kestrel.Transport.Abstractions/Internal/TransportConnection.Features.cs @@ -96,7 +96,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal set => LocalPort = value; } - BufferPool IConnectionTransportFeature.BufferPool => BufferPool; + MemoryPool IConnectionTransportFeature.MemoryPool => MemoryPool; IPipeConnection IConnectionTransportFeature.Transport { diff --git a/src/Kestrel.Transport.Abstractions/Internal/TransportConnection.cs b/src/Kestrel.Transport.Abstractions/Internal/TransportConnection.cs index df8247aa09..dc1af6ec56 100644 --- a/src/Kestrel.Transport.Abstractions/Internal/TransportConnection.cs +++ b/src/Kestrel.Transport.Abstractions/Internal/TransportConnection.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal public string ConnectionId { get; set; } - public virtual BufferPool BufferPool { get; } + public virtual MemoryPool MemoryPool { get; } public virtual IScheduler InputWriterScheduler { get; } public virtual IScheduler OutputReaderScheduler { get; } diff --git a/src/Kestrel.Transport.Libuv/Internal/LibuvConnectionContext.cs b/src/Kestrel.Transport.Libuv/Internal/LibuvConnectionContext.cs index 2f052becab..dde6aa5f30 100644 --- a/src/Kestrel.Transport.Libuv/Internal/LibuvConnectionContext.cs +++ b/src/Kestrel.Transport.Libuv/Internal/LibuvConnectionContext.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal public ListenerContext ListenerContext { get; set; } - public override BufferPool BufferPool => ListenerContext.Thread.BufferPool; + public override MemoryPool MemoryPool => ListenerContext.Thread.MemoryPool; public override IScheduler InputWriterScheduler => ListenerContext.Thread; public override IScheduler OutputReaderScheduler => ListenerContext.Thread; } diff --git a/src/Kestrel.Transport.Libuv/Internal/LibuvThread.cs b/src/Kestrel.Transport.Libuv/Internal/LibuvThread.cs index acab590fdc..ca9edc7445 100644 --- a/src/Kestrel.Transport.Libuv/Internal/LibuvThread.cs +++ b/src/Kestrel.Transport.Libuv/Internal/LibuvThread.cs @@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal #endif QueueCloseHandle = PostCloseHandle; QueueCloseAsyncHandle = EnqueueCloseHandle; - BufferPool = new MemoryPool(); + MemoryPool = new MemoryPool(); WriteReqPool = new WriteReqPool(this, _log); } @@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal public UvLoopHandle Loop { get { return _loop; } } - public BufferPool BufferPool { get; } + public MemoryPool MemoryPool { get; } public WriteReqPool WriteReqPool { get; } @@ -296,7 +296,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal } finally { - BufferPool.Dispose(); + MemoryPool.Dispose(); WriteReqPool.Dispose(); _threadTcs.SetResult(null); diff --git a/src/Kestrel.Transport.Sockets/Internal/SocketConnection.cs b/src/Kestrel.Transport.Sockets/Internal/SocketConnection.cs index 27f5807a1b..d74159792e 100644 --- a/src/Kestrel.Transport.Sockets/Internal/SocketConnection.cs +++ b/src/Kestrel.Transport.Sockets/Internal/SocketConnection.cs @@ -28,14 +28,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal private volatile bool _aborted; - internal SocketConnection(Socket socket, BufferPool bufferPool, ISocketsTrace trace) + internal SocketConnection(Socket socket, MemoryPool memoryPool, ISocketsTrace trace) { Debug.Assert(socket != null); - Debug.Assert(bufferPool != null); + Debug.Assert(memoryPool != null); Debug.Assert(trace != null); _socket = socket; - BufferPool = bufferPool; + MemoryPool = memoryPool; _trace = trace; var localEndPoint = (IPEndPoint)_socket.LocalEndPoint; @@ -51,7 +51,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal _sender = new SocketSender(_socket); } - public override BufferPool BufferPool { get; } + public override MemoryPool MemoryPool { get; } public override IScheduler InputWriterScheduler => InlineScheduler.Default; public override IScheduler OutputReaderScheduler => TaskRunScheduler.Default; diff --git a/src/Kestrel.Transport.Sockets/Internal/SocketSender.cs b/src/Kestrel.Transport.Sockets/Internal/SocketSender.cs index 688704811c..f871dc7021 100644 --- a/src/Kestrel.Transport.Sockets/Internal/SocketSender.cs +++ b/src/Kestrel.Transport.Sockets/Internal/SocketSender.cs @@ -31,7 +31,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal return SendAsync(buffers.First); } +#if NETCOREAPP2_1 + if (!_eventArgs.MemoryBuffer.Equals(Memory.Empty)) +#else if (_eventArgs.Buffer != null) +#endif { _eventArgs.SetBuffer(null, 0, 0); } diff --git a/src/Kestrel.Transport.Sockets/SocketTransport.cs b/src/Kestrel.Transport.Sockets/SocketTransport.cs index d4f056829f..6cec602c36 100644 --- a/src/Kestrel.Transport.Sockets/SocketTransport.cs +++ b/src/Kestrel.Transport.Sockets/SocketTransport.cs @@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets { internal sealed class SocketTransport : ITransport { - private readonly BufferPool _bufferPool = new MemoryPool(); + private readonly MemoryPool _memoryPool = new MemoryPool(); private readonly IEndPointInformation _endPointInformation; private readonly IConnectionHandler _handler; private readonly IApplicationLifetime _appLifetime; @@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets public Task StopAsync() { - _bufferPool.Dispose(); + _memoryPool.Dispose(); return Task.CompletedTask; } @@ -131,7 +131,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets var acceptSocket = await _listenSocket.AcceptAsync(); acceptSocket.NoDelay = _endPointInformation.NoDelay; - var connection = new SocketConnection(acceptSocket, _bufferPool, _trace); + var connection = new SocketConnection(acceptSocket, _memoryPool, _trace); _ = connection.StartAsync(_handler); } catch (SocketException ex) when (ex.SocketErrorCode == SocketError.ConnectionReset) diff --git a/src/Protocols.Abstractions/ConnectionContext.cs b/src/Protocols.Abstractions/ConnectionContext.cs index 586a2ae19b..afe2149576 100644 --- a/src/Protocols.Abstractions/ConnectionContext.cs +++ b/src/Protocols.Abstractions/ConnectionContext.cs @@ -15,6 +15,6 @@ namespace Microsoft.AspNetCore.Protocols public abstract IPipeConnection Transport { get; set; } - public abstract BufferPool BufferPool { get; } + public abstract MemoryPool MemoryPool { get; } } } diff --git a/src/Protocols.Abstractions/DefaultConnectionContext.cs b/src/Protocols.Abstractions/DefaultConnectionContext.cs index 0c34637735..047ed92eab 100644 --- a/src/Protocols.Abstractions/DefaultConnectionContext.cs +++ b/src/Protocols.Abstractions/DefaultConnectionContext.cs @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Protocols public override IFeatureCollection Features => _features.Collection; - public override BufferPool BufferPool => ConnectionTransportFeature.BufferPool; + public override MemoryPool MemoryPool => ConnectionTransportFeature.MemoryPool; public override IPipeConnection Transport { diff --git a/src/Protocols.Abstractions/Features/IConnectionTransportFeature.cs b/src/Protocols.Abstractions/Features/IConnectionTransportFeature.cs index 3fc8d86224..9a090437e8 100644 --- a/src/Protocols.Abstractions/Features/IConnectionTransportFeature.cs +++ b/src/Protocols.Abstractions/Features/IConnectionTransportFeature.cs @@ -6,7 +6,7 @@ namespace Microsoft.AspNetCore.Protocols.Features { public interface IConnectionTransportFeature { - BufferPool BufferPool { get; } + MemoryPool MemoryPool { get; } IPipeConnection Transport { get; set; } diff --git a/src/Protocols.Abstractions/PipeFactoryExtensions.cs b/src/Protocols.Abstractions/PipeFactoryExtensions.cs index f28207db59..e6b11e5654 100644 --- a/src/Protocols.Abstractions/PipeFactoryExtensions.cs +++ b/src/Protocols.Abstractions/PipeFactoryExtensions.cs @@ -4,7 +4,7 @@ namespace System.IO.Pipelines { public static class PipeFactory { - public static (IPipeConnection Transport, IPipeConnection Application) CreateConnectionPair(BufferPool memoryPool) + public static (IPipeConnection Transport, IPipeConnection Application) CreateConnectionPair(MemoryPool memoryPool) { return CreateConnectionPair(new PipeOptions(memoryPool), new PipeOptions(memoryPool)); } diff --git a/test/Kestrel.Core.Tests/ConnectionHandlerTests.cs b/test/Kestrel.Core.Tests/ConnectionHandlerTests.cs index e1ff59b297..5c7afd17f0 100644 --- a/test/Kestrel.Core.Tests/ConnectionHandlerTests.cs +++ b/test/Kestrel.Core.Tests/ConnectionHandlerTests.cs @@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Set(this); } - public BufferPool BufferPool { get; } = new MemoryPool(); + public MemoryPool MemoryPool { get; } = new MemoryPool(); public IPipeConnection Transport { get; set; } public IPipeConnection Application { get; set; } diff --git a/test/Kestrel.Core.Tests/Http1ConnectionTests.cs b/test/Kestrel.Core.Tests/Http1ConnectionTests.cs index 1efca25551..934bd31257 100644 --- a/test/Kestrel.Core.Tests/Http1ConnectionTests.cs +++ b/test/Kestrel.Core.Tests/Http1ConnectionTests.cs @@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests private readonly TestHttp1Connection _http1Connection; private readonly ServiceContext _serviceContext; private readonly Http1ConnectionContext _http1ConnectionContext; - private readonly BufferPool _pipelineFactory; + private readonly MemoryPool _pipelineFactory; private ReadCursor _consumed; private ReadCursor _examined; private Mock _timeoutControl; @@ -51,7 +51,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { ServiceContext = _serviceContext, ConnectionFeatures = new FeatureCollection(), - BufferPool = _pipelineFactory, + MemoryPool = _pipelineFactory, TimeoutControl = _timeoutControl.Object, Application = pair.Application, Transport = pair.Transport diff --git a/test/Kestrel.Core.Tests/Http2ConnectionTests.cs b/test/Kestrel.Core.Tests/Http2ConnectionTests.cs index 3f6d9a2a9c..a9976e08fb 100644 --- a/test/Kestrel.Core.Tests/Http2ConnectionTests.cs +++ b/test/Kestrel.Core.Tests/Http2ConnectionTests.cs @@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests private static readonly byte[] _noData = new byte[0]; private static readonly byte[] _maxData = Encoding.ASCII.GetBytes(new string('a', Http2Frame.MinAllowedMaxFrameSize)); - private readonly BufferPool _bufferPool = new MemoryPool(); + private readonly MemoryPool _memoryPool = new MemoryPool(); private readonly (IPipeConnection Transport, IPipeConnection Application) _pair; private readonly TestApplicationErrorLogger _logger; private readonly Http2ConnectionContext _connectionContext; @@ -122,7 +122,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests public Http2ConnectionTests() { - _pair = PipeFactory.CreateConnectionPair(_bufferPool); + _pair = PipeFactory.CreateConnectionPair(_memoryPool); _noopApplication = context => Task.CompletedTask; @@ -257,7 +257,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { Log = new TestKestrelTrace(_logger) }, - BufferPool = _bufferPool, + MemoryPool = _memoryPool, Application = _pair.Application, Transport = _pair.Transport }; @@ -266,7 +266,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests public void Dispose() { - _bufferPool.Dispose(); + _memoryPool.Dispose(); } void IHttpHeadersHandler.OnHeader(Span name, Span value) diff --git a/test/Kestrel.Core.Tests/HttpConnectionTests.cs b/test/Kestrel.Core.Tests/HttpConnectionTests.cs index dffd274f75..e426c22d21 100644 --- a/test/Kestrel.Core.Tests/HttpConnectionTests.cs +++ b/test/Kestrel.Core.Tests/HttpConnectionTests.cs @@ -18,21 +18,21 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { public class HttpConnectionTests : IDisposable { - private readonly BufferPool _bufferPool; + private readonly MemoryPool _memoryPool; private readonly HttpConnectionContext _httpConnectionContext; private readonly HttpConnection _httpConnection; public HttpConnectionTests() { - _bufferPool = new MemoryPool(); - var pair = PipeFactory.CreateConnectionPair(_bufferPool); + _memoryPool = new MemoryPool(); + var pair = PipeFactory.CreateConnectionPair(_memoryPool); _httpConnectionContext = new HttpConnectionContext { ConnectionId = "0123456789", ConnectionAdapters = new List(), ConnectionFeatures = new FeatureCollection(), - BufferPool = _bufferPool, + MemoryPool = _memoryPool, HttpConnectionId = long.MinValue, Application = pair.Application, Transport = pair.Transport, @@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests public void Dispose() { - _bufferPool.Dispose(); + _memoryPool.Dispose(); } [Fact] diff --git a/test/Kestrel.Core.Tests/HttpResponseHeadersTests.cs b/test/Kestrel.Core.Tests/HttpResponseHeadersTests.cs index b98a47c8e5..4634b758cf 100644 --- a/test/Kestrel.Core.Tests/HttpResponseHeadersTests.cs +++ b/test/Kestrel.Core.Tests/HttpResponseHeadersTests.cs @@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { ServiceContext = new TestServiceContext(), ConnectionFeatures = new FeatureCollection(), - BufferPool = memoryPool, + MemoryPool = memoryPool, Application = pair.Application, Transport = pair.Transport, TimeoutControl = null diff --git a/test/Kestrel.Core.Tests/OutputProducerTests.cs b/test/Kestrel.Core.Tests/OutputProducerTests.cs index ccfb164bad..77e21810f3 100644 --- a/test/Kestrel.Core.Tests/OutputProducerTests.cs +++ b/test/Kestrel.Core.Tests/OutputProducerTests.cs @@ -15,16 +15,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { public class OutputProducerTests : IDisposable { - private readonly BufferPool _bufferPool; + private readonly MemoryPool _memoryPool; public OutputProducerTests() { - _bufferPool = new MemoryPool(); + _memoryPool = new MemoryPool(); } public void Dispose() { - _bufferPool.Dispose(); + _memoryPool.Dispose(); } [Fact] @@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { var pipeOptions = new PipeOptions ( - bufferPool:_bufferPool, + pool: _memoryPool, readerScheduler: Mock.Of() ); diff --git a/test/Kestrel.Core.Tests/PipelineExtensionTests.cs b/test/Kestrel.Core.Tests/PipelineExtensionTests.cs index 954122f369..00cc9d1c2e 100644 --- a/test/Kestrel.Core.Tests/PipelineExtensionTests.cs +++ b/test/Kestrel.Core.Tests/PipelineExtensionTests.cs @@ -16,16 +16,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests private const int _ulongMaxValueLength = 20; private readonly IPipe _pipe; - private readonly BufferPool _bufferPool = new MemoryPool(); + private readonly MemoryPool _memoryPool = new MemoryPool(); public PipelineExtensionTests() { - _pipe = new Pipe(new PipeOptions(_bufferPool)); + _pipe = new Pipe(new PipeOptions(_memoryPool)); } public void Dispose() { - _bufferPool.Dispose(); + _memoryPool.Dispose(); } [Theory] diff --git a/test/Kestrel.Core.Tests/TestInput.cs b/test/Kestrel.Core.Tests/TestInput.cs index 76276f3858..ba644e4bf8 100644 --- a/test/Kestrel.Core.Tests/TestInput.cs +++ b/test/Kestrel.Core.Tests/TestInput.cs @@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests ConnectionFeatures = new FeatureCollection(), Application = Application, Transport = Transport, - BufferPool = _memoryPool, + MemoryPool = _memoryPool, TimeoutControl = Mock.Of() }; diff --git a/test/Kestrel.Transport.Libuv.Tests/LibuvConnectionTests.cs b/test/Kestrel.Transport.Libuv.Tests/LibuvConnectionTests.cs index 061dfcebf7..f6df1515e3 100644 --- a/test/Kestrel.Transport.Libuv.Tests/LibuvConnectionTests.cs +++ b/test/Kestrel.Transport.Libuv.Tests/LibuvConnectionTests.cs @@ -61,12 +61,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var thread = new LibuvThread(transport); mockConnectionHandler.InputOptions = pool => new PipeOptions( - bufferPool: pool, + pool: pool, maximumSizeHigh: 3); // We don't set the output writer scheduler here since we want to run the callback inline - mockConnectionHandler.OutputOptions = pool => new PipeOptions(bufferPool: pool, readerScheduler: thread); + mockConnectionHandler.OutputOptions = pool => new PipeOptions(pool: pool, readerScheduler: thread); Task connectionTask = null; @@ -125,12 +125,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests }); mockConnectionHandler.InputOptions = pool => new PipeOptions( - bufferPool: pool, + pool: pool, maximumSizeHigh: 3, maximumSizeLow: 3, writerScheduler: mockScheduler.Object); - mockConnectionHandler.OutputOptions = pool => new PipeOptions(bufferPool: pool, readerScheduler:thread ); + mockConnectionHandler.OutputOptions = pool => new PipeOptions(pool: pool, readerScheduler:thread ); Task connectionTask = null; try diff --git a/test/Kestrel.Transport.Libuv.Tests/LibuvOutputConsumerTests.cs b/test/Kestrel.Transport.Libuv.Tests/LibuvOutputConsumerTests.cs index da69f195ab..06576890d4 100644 --- a/test/Kestrel.Transport.Libuv.Tests/LibuvOutputConsumerTests.cs +++ b/test/Kestrel.Transport.Libuv.Tests/LibuvOutputConsumerTests.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests { public class LibuvOutputConsumerTests : IDisposable { - private readonly BufferPool _bufferPool; + private readonly MemoryPool _memoryPool; private readonly MockLibuv _mockLibuv; private readonly LibuvThread _libuvThread; @@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests public LibuvOutputConsumerTests() { - _bufferPool = new MemoryPool(); + _memoryPool = new MemoryPool(); _mockLibuv = new MockLibuv(); var libuvTransport = new LibuvTransport(_mockLibuv, new TestLibuvTransportContext(), new ListenOptions((ulong)0)); @@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests public void Dispose() { _libuvThread.StopAsync(TimeSpan.FromSeconds(1)).Wait(); - _bufferPool.Dispose(); + _memoryPool.Dispose(); } [Theory] @@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests // This is verified in PipeOptionsTests.OutputPipeOptionsConfiguredCorrectly. var pipeOptions = new PipeOptions ( - bufferPool: _bufferPool, + pool: _memoryPool, readerScheduler: _libuvThread, maximumSizeHigh: maxResponseBufferSize ?? 0, maximumSizeLow: maxResponseBufferSize ?? 0 @@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests // This is verified in PipeOptionsTests.OutputPipeOptionsConfiguredCorrectly. var pipeOptions = new PipeOptions ( - bufferPool: _bufferPool, + pool: _memoryPool, readerScheduler: _libuvThread, maximumSizeHigh: 0, maximumSizeLow: 0 @@ -148,7 +148,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests // This is verified in PipeOptionsTests.OutputPipeOptionsConfiguredCorrectly. var pipeOptions = new PipeOptions ( - bufferPool: _bufferPool, + pool: _memoryPool, readerScheduler: _libuvThread, maximumSizeHigh: 1, maximumSizeLow: 1 @@ -204,7 +204,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var pipeOptions = new PipeOptions ( - bufferPool: _bufferPool, + pool: _memoryPool, readerScheduler: _libuvThread, maximumSizeHigh: maxResponseBufferSize, maximumSizeLow: maxResponseBufferSize @@ -268,7 +268,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var pipeOptions = new PipeOptions ( - bufferPool: _bufferPool, + pool: _memoryPool, readerScheduler: _libuvThread, maximumSizeHigh: maxResponseBufferSize, maximumSizeLow: maxResponseBufferSize @@ -338,7 +338,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var pipeOptions = new PipeOptions ( - bufferPool: _bufferPool, + pool: _memoryPool, readerScheduler: _libuvThread, maximumSizeHigh: maxResponseBufferSize, maximumSizeLow: maxResponseBufferSize @@ -431,7 +431,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var pipeOptions = new PipeOptions ( - bufferPool: _bufferPool, + pool: _memoryPool, readerScheduler: _libuvThread, maximumSizeHigh: maxResponseBufferSize, maximumSizeLow: maxResponseBufferSize @@ -515,7 +515,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var pipeOptions = new PipeOptions ( - bufferPool: _bufferPool, + pool: _memoryPool, readerScheduler: _libuvThread, maximumSizeHigh: maxResponseBufferSize, maximumSizeLow: maxResponseBufferSize @@ -597,7 +597,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var pipeOptions = new PipeOptions ( - bufferPool: _bufferPool, + pool: _memoryPool, readerScheduler: _libuvThread, maximumSizeHigh: maxResponseBufferSize, maximumSizeLow: maxResponseBufferSize @@ -658,7 +658,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests // This is verified in PipeOptionsTests.OutputPipeOptionsConfiguredCorrectly. var pipeOptions = new PipeOptions ( - bufferPool: _bufferPool, + pool: _memoryPool, readerScheduler: _libuvThread, maximumSizeHigh: maxResponseBufferSize ?? 0, maximumSizeLow: maxResponseBufferSize ?? 0 @@ -712,7 +712,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), - BufferPool = _bufferPool, + MemoryPool = _memoryPool, TimeoutControl = Mock.Of(), Application = pair.Application, Transport = pair.Transport diff --git a/test/Kestrel.Transport.Libuv.Tests/TestHelpers/MockConnectionHandler.cs b/test/Kestrel.Transport.Libuv.Tests/TestHelpers/MockConnectionHandler.cs index 273f65f4d4..1efb0bedab 100644 --- a/test/Kestrel.Transport.Libuv.Tests/TestHelpers/MockConnectionHandler.cs +++ b/test/Kestrel.Transport.Libuv.Tests/TestHelpers/MockConnectionHandler.cs @@ -4,7 +4,6 @@ using System; using System.Buffers; using System.IO.Pipelines; -using System.Threading.Tasks; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Protocols; using Microsoft.AspNetCore.Protocols.Features; @@ -14,15 +13,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.TestHelpers { public class MockConnectionHandler : IConnectionHandler { - public Func InputOptions { get; set; } = pool => new PipeOptions(pool); - public Func OutputOptions { get; set; } = pool => new PipeOptions(pool); + public Func InputOptions { get; set; } = pool => new PipeOptions(pool); + public Func OutputOptions { get; set; } = pool => new PipeOptions(pool); public void OnConnection(IFeatureCollection features) { var connectionContext = new DefaultConnectionContext(features); - Input = new Pipe(InputOptions(connectionContext.BufferPool)); - Output = new Pipe(OutputOptions(connectionContext.BufferPool)); + Input = new Pipe(InputOptions(connectionContext.MemoryPool)); + Output = new Pipe(OutputOptions(connectionContext.MemoryPool)); var feature = connectionContext.Features.Get();