Skip to content

Commit de94540

Browse files
committed
flaky tests: fix orphaned worker thread
The WorkerSignals::worker keeps polling Query. When a test fails before calling destroy(), the server-side recording gets freed when OBS shuts down, but the orphaned worker thread continues. When the next test file creates a fresh OBS connection, Controller::GetInstance().GetConnection() now returns the new session's connection. The orphaned worker sends Query(oldUID) to the new server, which has no knowledge of that uid → "Recording reference is not valid."
1 parent f4d0f3b commit de94540

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class WorkerSignals {
3939
sleepIntervalMS = 33;
4040
workerThread = nullptr;
4141
};
42-
~WorkerSignals(){};
42+
~WorkerSignals() {};
4343

4444
protected:
4545
bool isWorkerRunning;
@@ -88,6 +88,15 @@ class WorkerSignals {
8888
auto conn = Controller::GetInstance().GetConnection();
8989
if (conn) {
9090
std::vector<ipc::value> response = conn->call_synchronous_helper(name, "Query", {ipc::value(refID)});
91+
if (!response.empty()) {
92+
ErrorCode firstError = (ErrorCode)response[0].value_union.ui64;
93+
if (firstError == ErrorCode::InvalidReference) {
94+
// This typically happens if the worker thread is orphaned.
95+
std::cout << "Worker thread exiting due to Invalid reference error encountered." << std::endl;
96+
isWorkerRunning = false;
97+
break;
98+
}
99+
}
91100
if ((response.size() == 5) && signalsList.size() < maximum_signals_in_queue) {
92101
ErrorCode error = (ErrorCode)response[0].value_union.ui64;
93102
if (error == ErrorCode::Ok) {
@@ -140,4 +149,4 @@ class WorkerSignals {
140149
workerThread->join();
141150
}
142151
}
143-
};
152+
};

0 commit comments

Comments
 (0)