Skip to content

Commit eab065c

Browse files
mkschulzeclaude
andcommitted
fix: remove SocketServer::wait() calls that block forever on shutdown
stop() fires _conditionVariable.notify_one() before wait() is called, so the notification is lost and wait() blocks the async teardown thread indefinitely. Since std::future from std::async has a blocking destructor, this hangs the plugin on unload, which on Windows cascades into BSOD. stop() already joins all IXWebSocket threads and closes the socket — wait() is unnecessary. Remove it from both stopWebSocketServer() and the destructor. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be82d94 commit eab065c

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

juce/video/VideoCompanion.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ VideoCompanion::~VideoCompanion()
4949
{
5050
wsServer_->setOnClientMessageCallback(nullptr);
5151
wsServer_->stop();
52-
wsServer_->wait();
5352
wsServer_.reset();
5453
}
5554
}
@@ -307,14 +306,15 @@ void VideoCompanion::stopWebSocketServer()
307306
// wsServer_ is now null — broadcastRoster/sendConfig will bail early
308307
}
309308

310-
// Wait + destroy off the message thread to avoid DAW state-save timeout.
311-
// WR-01 fix: Use std::async instead of detached thread so the destructor can
312-
// join the teardown task, preventing crashes from threads outliving the DLL.
309+
// Destroy the server object off the message thread to avoid DAW state-save timeout.
310+
// stop() above already joined all IXWebSocket threads and closed the socket.
311+
// DO NOT call s->wait() here — stop() already fired the condition variable notification,
312+
// so wait() would block forever (classic CV race: notify before wait = lost signal).
313+
// The async lambda only needs to destroy the unique_ptr, which is safe on any thread.
313314
if (serverToStop)
314315
{
315316
stopFuture_ = std::async(std::launch::async,
316317
[s = std::move(serverToStop)]() mutable {
317-
s->wait();
318318
s.reset();
319319
});
320320
}

src/build_number.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#pragma once
2-
#define JAMWIDE_BUILD_NUMBER 149
2+
#define JAMWIDE_BUILD_NUMBER 153

0 commit comments

Comments
 (0)