From fd6617d1019b8e5009ad3f8a8991483e8bff7eb1 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 26 Jul 2017 15:51:06 -0700 Subject: [PATCH] React to pipeline changes (#1969) --- .../Adapter/Internal/RawStream.cs | 3 ++- .../Internal/FrameConnection.cs | 4 ++-- .../Internal/Http/MessageBody.cs | 7 ++++--- .../Internal/Http/OutputProducer.cs | 2 +- .../Internal/Infrastructure/ITimeoutControl.cs | 4 ++-- .../Mocks/MockTimeoutControl.cs | 4 ++-- .../PipeThroughputBenchmark.cs | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Adapter/Internal/RawStream.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Adapter/Internal/RawStream.cs index 7b4ffc3340..94c318a8e3 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Adapter/Internal/RawStream.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Adapter/Internal/RawStream.cs @@ -105,7 +105,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal { if (!readableBuffer.IsEmpty) { - var count = Math.Min(readableBuffer.Length, buffer.Count); + // buffer.Count is int + var count = (int) Math.Min(readableBuffer.Length, buffer.Count); readableBuffer = readableBuffer.Slice(0, count); readableBuffer.CopyTo(buffer); return count; diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/FrameConnection.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/FrameConnection.cs index 85b754ce9c..0c033b2b9f 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/FrameConnection.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/FrameConnection.cs @@ -423,12 +423,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal } } - public void BytesRead(int count) + public void BytesRead(long count) { Interlocked.Add(ref _readTimingBytesRead, count); } - public void StartTimingWrite(int size) + public void StartTimingWrite(long size) { lock (_writeTimingLock) { diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/MessageBody.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/MessageBody.cs index 407dc15ec3..3ce0cd76ea 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/MessageBody.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/MessageBody.cs @@ -147,7 +147,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http { if (!readableBuffer.IsEmpty) { - var actual = Math.Min(readableBuffer.Length, buffer.Count); + // buffer.Count is int + var actual = (int) Math.Min(readableBuffer.Length, buffer.Count); var slice = readableBuffer.Slice(0, actual); consumed = readableBuffer.Move(readableBuffer.Start, actual); slice.CopyTo(buffer); @@ -476,7 +477,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http // "7FFFFFFF\r\n" is the largest chunk size that could be returned as an int. private const int MaxChunkPrefixBytes = 10; - private int _inputLength; + private long _inputLength; private long _consumedBytes; private Mode _mode = Mode.Prefix; @@ -568,7 +569,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http return _mode == Mode.Complete; } - private void AddAndCheckConsumedBytes(int consumedBytes) + private void AddAndCheckConsumedBytes(long consumedBytes) { _consumedBytes += consumedBytes; diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/OutputProducer.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/OutputProducer.cs index d9fce78492..51ed5c1f67 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/OutputProducer.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/OutputProducer.cs @@ -155,7 +155,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http return FlushAsyncAwaited(awaitable, writableBuffer.BytesWritten, cancellationToken); } - private async Task FlushAsyncAwaited(WritableBufferAwaitable awaitable, int count, CancellationToken cancellationToken) + private async Task FlushAsyncAwaited(WritableBufferAwaitable awaitable, long count, CancellationToken cancellationToken) { // https://github.com/dotnet/corefxlab/issues/1334 // Since the flush awaitable doesn't currently support multiple awaiters diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Infrastructure/ITimeoutControl.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Infrastructure/ITimeoutControl.cs index 4ed025ac72..2e2c34ff55 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Infrastructure/ITimeoutControl.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Infrastructure/ITimeoutControl.cs @@ -15,9 +15,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure void PauseTimingReads(); void ResumeTimingReads(); void StopTimingReads(); - void BytesRead(int count); + void BytesRead(long count); - void StartTimingWrite(int size); + void StartTimingWrite(long size); void StopTimingWrite(); } } diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Mocks/MockTimeoutControl.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Mocks/MockTimeoutControl.cs index e0a54ef642..24f76b8203 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Mocks/MockTimeoutControl.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Mocks/MockTimeoutControl.cs @@ -37,11 +37,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance.Mocks { } - public void BytesRead(int count) + public void BytesRead(long count) { } - public void StartTimingWrite(int size) + public void StartTimingWrite(long size) { } diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/PipeThroughputBenchmark.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/PipeThroughputBenchmark.cs index 152f8af1ef..09d79ed693 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/PipeThroughputBenchmark.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/PipeThroughputBenchmark.cs @@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance var reading = Task.Run(async () => { - int remaining = InnerLoopCount * _writeLenght; + long remaining = InnerLoopCount * _writeLenght; while (remaining != 0) { var result = await _pipe.Reader.ReadAsync();