Skip to content

Commit

Permalink
Fix dead lock on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyStreamlabs committed Oct 24, 2018
1 parent 7c112ad commit 6b0bfd8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion obs-studio-server/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,22 @@ int main(int argc, char* argv[])
// Reset Connect/Disconnect time.
sd.last_disconnect = sd.last_connect = std::chrono::high_resolution_clock::now();

bool waitBeforeClosing = false;

while (!doShutdown) {
if (sd.count_connected == 0) {
auto tp = std::chrono::high_resolution_clock::now();
auto delta = tp - sd.last_disconnect;
if (std::chrono::duration_cast<std::chrono::milliseconds>(delta).count() > 5000) {
doShutdown = true;
waitBeforeClosing = true;
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}

// Wait on receive the exit message from the crash-handler
{
if (waitBeforeClosing) {
HANDLE hPipe;
TCHAR chBuf[BUFFSIZE];
DWORD cbRead;
Expand Down

0 comments on commit 6b0bfd8

Please sign in to comment.