mirror of
https://github.com/dashpay/dash.git
synced 2024-12-30 14:25:53 +01:00
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
@ -25,6 +25,7 @@ namespace boost {
|
|||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
#include <boost/thread.hpp>
|
||||||
#include <openssl/crypto.h>
|
#include <openssl/crypto.h>
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -209,6 +210,8 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
|
|||||||
if (fileout)
|
if (fileout)
|
||||||
{
|
{
|
||||||
static bool fStartedNewLine = true;
|
static bool fStartedNewLine = true;
|
||||||
|
static boost::mutex mutexDebugLog;
|
||||||
|
boost::mutex::scoped_lock scoped_lock(mutexDebugLog);
|
||||||
|
|
||||||
// Debug print useful for profiling
|
// Debug print useful for profiling
|
||||||
if (fLogTimestamps && fStartedNewLine)
|
if (fLogTimestamps && fStartedNewLine)
|
||||||
|
Loading…
Reference in New Issue
Block a user