Skip to content

Commit 6b0bfd8

Browse files
author
eddyStreamlabs
committed
Fix dead lock on exit
1 parent 7c112ad commit 6b0bfd8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

obs-studio-server/source/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,22 @@ int main(int argc, char* argv[])
198198
// Reset Connect/Disconnect time.
199199
sd.last_disconnect = sd.last_connect = std::chrono::high_resolution_clock::now();
200200

201+
bool waitBeforeClosing = false;
202+
201203
while (!doShutdown) {
202204
if (sd.count_connected == 0) {
203205
auto tp = std::chrono::high_resolution_clock::now();
204206
auto delta = tp - sd.last_disconnect;
205207
if (std::chrono::duration_cast<std::chrono::milliseconds>(delta).count() > 5000) {
206208
doShutdown = true;
209+
waitBeforeClosing = true;
207210
}
208211
}
209212
std::this_thread::sleep_for(std::chrono::milliseconds(50));
210213
}
211214

212215
// Wait on receive the exit message from the crash-handler
213-
{
216+
if (waitBeforeClosing) {
214217
HANDLE hPipe;
215218
TCHAR chBuf[BUFFSIZE];
216219
DWORD cbRead;

0 commit comments

Comments
 (0)