From 7527c7340fbe14925fb3f552f75a69ff58e887ba Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 28 Jun 2025 00:29:21 -0500 Subject: [PATCH] yet another workaround to a deadlock in the log th read a really stupid workaround but why does notify_one not work --- src/log.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/log.cpp b/src/log.cpp index 8e01358e1..617a567b6 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -43,6 +43,7 @@ std::mutex logFileLock; std::mutex logFileLockI; std::condition_variable logFileNotify; std::atomic logFileAvail(false); +std::atomic iAmReallyDead(false); std::atomic logPosition; @@ -200,6 +201,7 @@ void _logFileThread() { logFileNotify.wait(lock); } } + iAmReallyDead=true; } bool startLogFile(const char* path) { @@ -247,10 +249,16 @@ bool finishLogFile() { if (!logFileAvail) return false; logFileAvail=false; + iAmReallyDead=false; // flush logFileLockI.lock(); logFileNotify.notify_one(); + while (!iAmReallyDead) { + std::this_thread::yield(); + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + } + // this join is guaranteed to work logFileThread->join(); logFileLockI.unlock();