Skip to content

Remove bad IsCompleted Check #7933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/Servers/Kestrel/Core/src/Internal/Http2/Http2Stream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,16 @@ public Task OnDataAsync(Http2Frame dataFrame, ReadOnlySequence<byte> payload)
{
RequestBodyPipe.Writer.Write(segment.Span);
}
var flushTask = RequestBodyPipe.Writer.FlushAsync();

// It shouldn't be possible for the RequestBodyPipe to fill up an return an incomplete task if
// _inputFlowControl.Advance() didn't throw.
Debug.Assert(flushTask.IsCompleted);
// If the stream is completed go ahead and call RequestBodyPipe.Writer.Complete().
// Data will still be available to the reader.
if (!endStream)
{
var flushTask = RequestBodyPipe.Writer.FlushAsync();
// It shouldn't be possible for the RequestBodyPipe to fill up an return an incomplete task if
// _inputFlowControl.Advance() didn't throw.
Debug.Assert(flushTask.IsCompleted);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,8 @@ public async Task ContentLength_Received_ReadViaPipes()
await InitializeConnectionAsync(async context =>
{
var readResult = await context.Request.BodyPipe.ReadAsync();
Assert.Equal(12, readResult.Buffer.Length);
Assert.True(readResult.IsCompleted);
Assert.Equal(12, readResult.Buffer.Length);
context.Request.BodyPipe.AdvanceTo(readResult.Buffer.End);

readResult = await context.Request.BodyPipe.ReadAsync();
Expand Down