Improved Send100 Check

This commit is contained in:
Ben Adams 2015-11-16 06:43:49 +00:00
parent ecc439555e
commit 7691a7cc23
1 changed files with 7 additions and 4 deletions

View File

@ -41,17 +41,20 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
public async Task Consume(CancellationToken cancellationToken = default(CancellationToken)) public async Task Consume(CancellationToken cancellationToken = default(CancellationToken))
{ {
Task<int> result; Task<int> result;
var firstLoop = true; var send100checked = false;
do do
{ {
result = ReadAsyncImplementation(default(ArraySegment<byte>), cancellationToken); result = ReadAsyncImplementation(default(ArraySegment<byte>), cancellationToken);
if (!result.IsCompleted) if (!result.IsCompleted)
{ {
if (firstLoop && Interlocked.Exchange(ref _send100Continue, 0) == 1) if (!send100checked)
{
if (Interlocked.Exchange(ref _send100Continue, 0) == 1)
{ {
firstLoop = false;
_context.FrameControl.ProduceContinue(); _context.FrameControl.ProduceContinue();
} }
send100checked = true;
}
} }
else if (result.GetAwaiter().GetResult() == 0) else if (result.GetAwaiter().GetResult() == 0)
{ {