Skip to content
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

Avoid race condition in EventSource_ConnectionPoolAtMaxConnections_LogsRequestLeftQueue #52887

Merged
merged 1 commit into from
May 18, 2021
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 @@ -585,6 +585,7 @@ await listener.RunWithCallbackAsync(e => events.Enqueue((e, e.ActivityId)), asyn
{
var firstRequestReceived = new SemaphoreSlim(0, 1);
var secondRequestSent = new SemaphoreSlim(0, 1);
var firstRequestFinished = new SemaphoreSlim(0, 1);

await GetFactoryForVersion(version).CreateClientAndServerAsync(
async uri =>
Expand All @@ -605,7 +606,13 @@ await GetFactoryForVersion(version).CreateClientAndServerAsync(
Task secondRequest = client.GetStringAsync(uri);
secondRequestSent.Release();

await new[] { firstRequest, secondRequest }.WhenAllOrAnyFailed();
// We are asserting that ActivityIds between Start/Stop pairs match below
// We wait for the first request to finish to ensure that RequestStop events
// are logged in the same order as RequestStarts
await firstRequest;
firstRequestFinished.Release();

await secondRequest;
},
async server =>
{
Expand Down Expand Up @@ -634,6 +641,7 @@ await GetFactoryForVersion(version).CreateClientAndServerAsync(
await connection.SendResponseAsync();

// Second request
Assert.True(await firstRequestFinished.WaitAsync(TimeSpan.FromSeconds(10)));
await connection.ReadRequestDataAsync(readBody: false);
await connection.SendResponseAsync();
};
Expand Down