Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,11 @@ public async Task StreamPool_SingleStream_ReturnedToPool()
{
// Add stream to Http2Connection._completedStreams inline with SetResult().
var serverTcs = new TaskCompletionSource();
var appTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);

await InitializeConnectionAsync(async context =>
{
appTcs.TrySetResult();
await serverTcs.Task;
await _echoApplication(context);
});
Expand All @@ -415,6 +417,8 @@ await InitializeConnectionAsync(async context =>

await StartStreamAsync(1, _browserRequestHeaders, endStream: true);

// If app code is running we know the stream has been created
await appTcs.Task;
var stream = _connection._streams[1];
serverTcs.SetResult();

Expand Down Expand Up @@ -490,9 +494,12 @@ public async Task StreamPool_MultipleStreamsInSequence_PooledStreamReused()
TaskCompletionSource appDelegateTcs = null;
object persistedState = null;
var requestCount = 0;
var appTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);

await InitializeConnectionAsync(async context =>
{
appTcs.TrySetResult();

requestCount++;
var persistentStateCollection = context.Features.Get<IPersistentStateFeature>().State;
if (persistentStateCollection.TryGetValue("Counter", out var value))
Expand All @@ -509,6 +516,9 @@ await InitializeConnectionAsync(async context =>
appDelegateTcs = new TaskCompletionSource();
await StartStreamAsync(1, _browserRequestHeaders, endStream: true);

// If app code is running we know the stream has been created
await appTcs.Task;
appTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
// Get the in progress stream
var stream = _connection._streams[1];

Expand All @@ -534,6 +544,8 @@ await ExpectAsync(Http2FrameType.HEADERS,
appDelegateTcs = new TaskCompletionSource();
await StartStreamAsync(3, _browserRequestHeaders, endStream: true);

await appTcs.Task;

// New stream has been taken from the pool
Assert.Equal(0, _connection.StreamPool.Count);

Expand Down Expand Up @@ -564,9 +576,11 @@ public async Task StreamPool_StreamIsInvalidState_DontReturnedToPool()
{
// Add (or don't add) stream to Http2Connection._completedStreams inline with SetResult().
var serverTcs = new TaskCompletionSource();
var appTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);

await InitializeConnectionAsync(async context =>
{
appTcs.TrySetResult();
await serverTcs.Task.DefaultTimeout();

await context.Response.WriteAsync("Content");
Expand All @@ -575,6 +589,8 @@ await InitializeConnectionAsync(async context =>

await StartStreamAsync(1, _browserRequestHeaders, endStream: true);

// If app code is running we know the stream has been created
await appTcs.Task;
var stream = _connection._streams[1];
serverTcs.SetResult();

Expand Down
Loading