Skip to content

Commit c194e76

Browse files
Fix race in event_tracer/repeat unit tests (#139)
* Fix race in event_tracer * Repeat unit tests 100 times in CI to catch instability
1 parent f7a8df1 commit c194e76

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

.github/workflows/tests.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,22 @@ jobs:
198198
# ---------- Run unit tests ----------
199199
- name: Run unit tests (Unix)
200200
if: runner.os != 'Windows'
201-
timeout-minutes: 1
201+
timeout-minutes: 10
202202
shell: bash
203203
run: |
204204
build-release/bin/livekit_unit_tests \
205+
--gtest_repeat=100 \
206+
--gtest_brief=1 \
205207
--gtest_output=xml:build-release/unit-test-results.xml
206208
207209
- name: Run unit tests (Windows)
208210
if: runner.os == 'Windows'
209-
timeout-minutes: 1
211+
timeout-minutes: 10
210212
shell: pwsh
211213
run: |
212214
build-release\bin\livekit_unit_tests.exe `
215+
--gtest_repeat=100 `
216+
--gtest_brief=1 `
213217
--gtest_output="xml:build-release\unit-test-results.xml"
214218
215219
# ---------- Install + start livekit-server for integration tests ----------

src/trace/event_tracer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,12 @@ void StopTracing() {
408408
// Disable tracing first to stop new events
409409
g_tracing_enabled.store(false, std::memory_order_release);
410410

411-
// Signal writer thread to shut down
412-
g_shutdown_requested.store(true);
411+
// Signal writer thread to shut down. The shutdown flag must be set while
412+
// holding g_mutex so the writer thread cannot miss the notification
413+
{
414+
const std::scoped_lock<std::mutex> lock(g_mutex);
415+
g_shutdown_requested.store(true);
416+
}
413417
g_cv.notify_one();
414418

415419
// Wait for writer thread to finish

0 commit comments

Comments
 (0)