mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
Make OutputDebugStringF thread-safe again (thanks ArtForz for catching)
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@182 1a98c847-1fd6-4fd8-948a-caf3550aa51b
This commit is contained in:
parent
026c5f7617
commit
2f7a9997c8
48
util.cpp
48
util.cpp
@ -145,6 +145,8 @@ int GetRandInt(int nMax)
|
|||||||
|
|
||||||
inline int OutputDebugStringF(const char* pszFormat, ...)
|
inline int OutputDebugStringF(const char* pszFormat, ...)
|
||||||
{
|
{
|
||||||
|
static CCriticalSection cs_OutputDebugStringF;
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (fPrintToConsole)
|
if (fPrintToConsole)
|
||||||
{
|
{
|
||||||
@ -156,29 +158,32 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// print to debug.log
|
CRITICAL_BLOCK(cs_OutputDebugStringF)
|
||||||
static FILE* fileout = NULL;
|
{
|
||||||
static int64 nOpenTime = 0;
|
// print to debug.log
|
||||||
|
static FILE* fileout = NULL;
|
||||||
|
static int64 nOpenTime = 0;
|
||||||
|
|
||||||
if (GetTime()-nOpenTime > 10 * 60)
|
if (GetTime()-nOpenTime > 10 * 60)
|
||||||
{
|
{
|
||||||
|
if (fileout)
|
||||||
|
fclose(fileout);
|
||||||
|
char pszFile[MAX_PATH+100];
|
||||||
|
GetDataDir(pszFile);
|
||||||
|
strlcat(pszFile, "/debug.log", sizeof(pszFile));
|
||||||
|
fileout = fopen(pszFile, "a");
|
||||||
|
nOpenTime = GetTime();
|
||||||
|
}
|
||||||
if (fileout)
|
if (fileout)
|
||||||
fclose(fileout);
|
{
|
||||||
char pszFile[MAX_PATH+100];
|
//// Debug print useful for profiling
|
||||||
GetDataDir(pszFile);
|
//fprintf(fileout, " %"PRI64d" ", GetTimeMillis());
|
||||||
strlcat(pszFile, "/debug.log", sizeof(pszFile));
|
va_list arg_ptr;
|
||||||
fileout = fopen(pszFile, "a");
|
va_start(arg_ptr, pszFormat);
|
||||||
nOpenTime = GetTime();
|
ret = vfprintf(fileout, pszFormat, arg_ptr);
|
||||||
}
|
va_end(arg_ptr);
|
||||||
if (fileout)
|
fflush(fileout);
|
||||||
{
|
}
|
||||||
//// Debug print useful for profiling
|
|
||||||
//fprintf(fileout, " %"PRI64d" ", GetTimeMillis());
|
|
||||||
va_list arg_ptr;
|
|
||||||
va_start(arg_ptr, pszFormat);
|
|
||||||
ret = vfprintf(fileout, pszFormat, arg_ptr);
|
|
||||||
va_end(arg_ptr);
|
|
||||||
fflush(fileout);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +191,6 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
|
|||||||
if (fPrintToDebugger)
|
if (fPrintToDebugger)
|
||||||
{
|
{
|
||||||
// accumulate a line at a time
|
// accumulate a line at a time
|
||||||
static CCriticalSection cs_OutputDebugStringF;
|
|
||||||
CRITICAL_BLOCK(cs_OutputDebugStringF)
|
CRITICAL_BLOCK(cs_OutputDebugStringF)
|
||||||
{
|
{
|
||||||
static char pszBuffer[50000];
|
static char pszBuffer[50000];
|
||||||
|
Loading…
Reference in New Issue
Block a user