Skip to content

Commit ebd0ac2

Browse files
committed
validate totalSleepMS does not have a negative value
When the IPC call takes longer than sleepIntervalMS on an overloaded CI runner), sleepIntervalMS - dur.count() produces a negative result that wraps to a huge size_t value, causing the worker to sleep for an effectively infinite duration. After that, no more signals are ever polled — any test waiting for a signal hits the 30-second timeout.
1 parent c50fe78 commit ebd0ac2

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

obs-studio-client/source/nodeobs_service.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ void service::worker()
348348

349349
auto tp_end = std::chrono::high_resolution_clock::now();
350350
auto dur = std::chrono::duration_cast<std::chrono::milliseconds>(tp_end - tp_start);
351-
totalSleepMS = sleepIntervalMS - dur.count();
351+
auto durCount = dur.count();
352+
totalSleepMS = durCount < sleepIntervalMS ? sleepIntervalMS - durCount : 0;
352353
std::this_thread::sleep_for(std::chrono::milliseconds(totalSleepMS));
353354
}
354355

obs-studio-client/source/worker-signals.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ class WorkerSignals {
132132

133133
auto tp_end = std::chrono::high_resolution_clock::now();
134134
auto dur = std::chrono::duration_cast<std::chrono::milliseconds>(tp_end - tp_start);
135-
totalSleepMS = sleepIntervalMS - dur.count();
135+
auto durCount = dur.count();
136+
totalSleepMS = durCount < sleepIntervalMS ? sleepIntervalMS - durCount : 0;
136137
std::this_thread::sleep_for(std::chrono::milliseconds(totalSleepMS));
137138
}
138139

0 commit comments

Comments
 (0)