# HG changeset patch # User Michael Hendricks # Date 1330716278 25200 # Node ID bf012cfbf48955365519d44b1f503e6e178d0e70 # Parent d46f72be1f10f5c3913db87158726ac5e14b1593 Serialize access to debug.log stream Acquire an exclusive, advisory lock before sending output to debug.log and release it when we're done. This should avoid output from multiple threads being interspersed in the log file. We can't use CRITICAL_SECTION machinery for this because the debug log is written during startup and shutdown when that machinery is not available. (Thanks to Gavin for pointing out the CRITICAL_SECTION problems based on his earlier work in this area) diff --git a/src/util.cpp b/src/util.cpp --- a/src/util.cpp +++ b/src/util.cpp @@ -22,6 +22,7 @@ #include #include #include +#include using namespace std; using namespace boost; @@ -193,6 +194,8 @@ if (fileout) { static bool fStartedNewLine = true; + static boost::mutex mutexDebugLog; + boost::mutex::scoped_lock scoped_lock(mutexDebugLog); // Debug print useful for profiling if (fLogTimestamps && fStartedNewLine)