diff --git a/Directory.Build.props b/Directory.Build.props index ed8924e122..5a6091cbfe 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,4 +12,10 @@ true true + + + + + + diff --git a/build/dependencies.props b/build/dependencies.props index 94936eaa6a..c5719a5f51 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -26,14 +26,15 @@ 2.1.0-preview1-27496 2.1.0-preview1-27496 2.0.0 + 2.6.0-beta2-62211-02 15.3.0 4.4.0 - 0.1.0-e170811-6 - 4.4.0-preview3-25519-03 - 4.4.0 - 4.4.0 + 0.1.0-alpha-002 + 4.5.0-preview1-25902-08 + 4.5.0-preview1-25902-08 + 4.5.0-preview1-25902-08 4.4.0 - 0.1.0-e170811-6 + 0.1.0-alpha-002 2.3.0 2.3.0 diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.cs index db83adc7cb..4b7f3c12d7 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.cs @@ -41,10 +41,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration protected Stack, object>> _onCompleted; protected Exception _applicationException; - private readonly PipeFactory _pipeFactory; + private readonly BufferPool _bufferPool; private GCHandle _thisHandle; - private BufferHandle _inputHandle; + private MemoryHandle _inputHandle; private IISAwaitable _operation = new IISAwaitable(); private IISAwaitable _readWebSocketsOperation; @@ -64,12 +64,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration private const string NegotiateString = "Negotiate"; private const string BasicString = "Basic"; - internal unsafe IISHttpContext(PipeFactory pipeFactory, IntPtr pHttpContext, IISOptions options) + internal unsafe IISHttpContext(BufferPool bufferPool, IntPtr pHttpContext, IISOptions options) : base((HttpApiTypes.HTTP_REQUEST*)NativeMethods.http_get_raw_request(pHttpContext)) { _thisHandle = GCHandle.Alloc(this); - _pipeFactory = pipeFactory; + _bufferPool = bufferPool; _pHttpContext = pHttpContext; NativeMethods.http_set_managed_context(_pHttpContext, (IntPtr)_thisHandle); @@ -142,8 +142,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration RequestBody = new IISHttpRequestBody(this); ResponseBody = new IISHttpResponseBody(this); - Input = _pipeFactory.Create(new PipeOptions { ReaderScheduler = TaskRunScheduler.Default }); - var pipe = _pipeFactory.Create(new PipeOptions { ReaderScheduler = TaskRunScheduler.Default }); + Input = new Pipe(new PipeOptions(_bufferPool, readerScheduler: TaskRunScheduler.Default)); + var pipe = new Pipe(new PipeOptions(_bufferPool, readerScheduler: TaskRunScheduler.Default)); Output = new OutputProducer(pipe); } @@ -609,7 +609,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration // REVIEW: We don't really need this list since the memory is already pinned with the default pool, // but shouldn't assume the pool implementation right now. Unfortunately, this causes a heap allocation... - var handles = new BufferHandle[nChunks]; + var handles = new MemoryHandle[nChunks]; foreach (var b in buffer) { @@ -620,7 +620,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration chunk.DataChunkType = HttpApiTypes.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory; chunk.fromMemory.BufferLength = (uint)b.Length; - chunk.fromMemory.pBuffer = (IntPtr)handle.PinnedPointer; + chunk.fromMemory.pBuffer = (IntPtr)handle.Pointer; currentChunk++; } @@ -661,7 +661,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration { var hr = NativeMethods.http_read_request_bytes( _pHttpContext, - (byte*)_inputHandle.PinnedPointer, + (byte*)_inputHandle.Pointer, length, out var dwReceivedBytes, out bool fCompletionExpected); @@ -679,7 +679,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration bool fCompletionExpected; hr = NativeMethods.http_websockets_read_bytes( _pHttpContext, - (byte*)_inputHandle.PinnedPointer, + (byte*)_inputHandle.Pointer, length, IISAwaitable.ReadCallback, (IntPtr)_thisHandle, diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContextOfT.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContextOfT.cs index 1701122ec6..5d326b27b1 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContextOfT.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContextOfT.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.Buffers; using System.Threading.Tasks; using System.Threading; using System.IO.Pipelines; @@ -14,8 +15,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration { private readonly IHttpApplication _application; - public IISHttpContextOfT(PipeFactory pipeFactory, IHttpApplication application, IntPtr pHttpContext, IISOptions options) - : base(pipeFactory, pHttpContext, options) + public IISHttpContextOfT(BufferPool bufferPool, IHttpApplication application, IntPtr pHttpContext, IISOptions options) + : base(bufferPool, pHttpContext, options) { _application = application; } diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs index 4417e54c5b..a02e1fac1c 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.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.Buffers; using System.IO.Pipelines; using System.Runtime.InteropServices; using System.Threading; @@ -22,7 +23,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration private static NativeMethods.PFN_ASYNC_COMPLETION _onAsyncCompletion = OnAsyncCompletion; private IISContextFactory _iisContextFactory; - private PipeFactory _pipeFactory = new PipeFactory(); + private readonly BufferPool _bufferPool = new MemoryPool(); private GCHandle _httpServerHandle; private readonly IApplicationLifetime _applicationLifetime; private readonly IAuthenticationSchemeProvider _authentication; @@ -45,7 +46,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration { _httpServerHandle = GCHandle.Alloc(this); - _iisContextFactory = new IISContextFactory(_pipeFactory, application, _options); + _iisContextFactory = new IISContextFactory(_bufferPool, application, _options); // Start the server by registering the callback NativeMethods.register_callbacks(_requestHandler, _shutdownHandler, _onAsyncCompletion, (IntPtr)_httpServerHandle, (IntPtr)_httpServerHandle); @@ -69,7 +70,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration _httpServerHandle.Free(); } - _pipeFactory.Dispose(); + _bufferPool.Dispose(); } private static NativeMethods.REQUEST_NOTIFICATION_STATUS HandleRequest(IntPtr pHttpContext, IntPtr pvRequestContext) @@ -125,19 +126,19 @@ namespace Microsoft.AspNetCore.Server.IISIntegration private class IISContextFactory : IISContextFactory { private readonly IHttpApplication _application; - private readonly PipeFactory _pipeFactory; + private readonly BufferPool _bufferPool; private readonly IISOptions _options; - public IISContextFactory(PipeFactory pipeFactory, IHttpApplication application, IISOptions options) + public IISContextFactory(BufferPool bufferPool, IHttpApplication application, IISOptions options) { _application = application; - _pipeFactory = pipeFactory; + _bufferPool = bufferPool; _options = options; } public IISHttpContext CreateHttpContext(IntPtr pHttpContext) { - return new IISHttpContextOfT(_pipeFactory, _application, pHttpContext, _options); + return new IISHttpContextOfT(_bufferPool, _application, pHttpContext, _options); } } } diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/OutputProducer.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/OutputProducer.cs index 57391e80de..d469dd4d88 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/OutputProducer.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/OutputProducer.cs @@ -107,10 +107,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration // The flush task can't fail today return Task.CompletedTask; } - return FlushAsyncAwaited(awaitable, writableBuffer.BytesWritten, cancellationToken); + return FlushAsyncAwaited(awaitable, cancellationToken); } - private async Task FlushAsyncAwaited(WritableBufferAwaitable awaitable, long count, CancellationToken cancellationToken) + private async Task FlushAsyncAwaited(WritableBufferAwaitable awaitable, CancellationToken cancellationToken) { // https://github.com/dotnet/corefxlab/issues/1334 // Since the flush awaitable doesn't currently support multiple awaiters