Skip to content

Commit

Permalink
Fix racing condition
Browse files Browse the repository at this point in the history
  • Loading branch information
vplauzon committed Oct 25, 2023
1 parent 0dc3a16 commit 39ac400
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion code/DeltaKustoAdxIntegrationTest/AdxDbTestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public async Task<IImmutableList<string>> GetDbsAsync(int dbCount)
}
// Not enough db available: let's wait for some!
await newDbEvent.Task;
// Change the event for a fresh one
Interlocked.CompareExchange(
ref _newDbEvent,
new TaskCompletionSource(),
Expand All @@ -142,7 +143,7 @@ public void ReleaseDbs(IEnumerable<string> dbNames)
_availableDbNames.AddRange(dbNames);
}
// Pop event for waiting threads
_newDbEvent.SetResult();
_newDbEvent.TrySetResult();
}

void IDisposable.Dispose()
Expand Down

0 comments on commit 39ac400

Please sign in to comment.