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)
This commit is contained in:
parent
660ff174f2
commit
fea25712ca
1 changed files with 3 additions and 0 deletions
|
@ -25,6 +25,7 @@ namespace boost {
|
|||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -209,6 +210,8 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue