aboutsummaryrefslogtreecommitdiff
path: root/util.cpp
diff options
context:
space:
mode:
authorgavinandresen <gavinandresen@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-11-18 00:11:33 +0000
committergavinandresen <gavinandresen@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-11-18 00:11:33 +0000
commitc4679ad0f1d4370d2d441c5091358d16854b8102 (patch)
treeba352d4499a8bae0c71e07c0640052c9fce964c7 /util.cpp
parent2f7a9997c88822696edbad38b14c5658c4630e9d (diff)
OutputDebugStringF fix for Mac FileVault problem, take 3
(cannot use a CRITICAL_BLOCK because of undefined order calling static destructors; instead, keep debug.log open, and tell people to use copytruncate when doing log rotation) git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@183 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'util.cpp')
-rw-r--r--util.cpp47
1 files changed, 20 insertions, 27 deletions
diff --git a/util.cpp b/util.cpp
index 771c65788f..7576beabaa 100644
--- a/util.cpp
+++ b/util.cpp
@@ -145,8 +145,6 @@ int GetRandInt(int nMax)
inline int OutputDebugStringF(const char* pszFormat, ...)
{
- static CCriticalSection cs_OutputDebugStringF;
-
int ret = 0;
if (fPrintToConsole)
{
@@ -158,38 +156,33 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
}
else
{
- CRITICAL_BLOCK(cs_OutputDebugStringF)
- {
- // print to debug.log
- static FILE* fileout = NULL;
- static int64 nOpenTime = 0;
+ // print to debug.log
+ static FILE* fileout = NULL;
- 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)
- {
- //// 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);
- }
+ if (!fileout)
+ {
+ char pszFile[MAX_PATH+100];
+ GetDataDir(pszFile);
+ strlcat(pszFile, "/debug.log", sizeof(pszFile));
+ fileout = fopen(pszFile, "a");
+ setbuf(fileout, NULL); // unbuffered
+ }
+ if (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);
}
}
#ifdef __WXMSW__
if (fPrintToDebugger)
{
+ static CCriticalSection cs_OutputDebugStringF;
+
// accumulate a line at a time
CRITICAL_BLOCK(cs_OutputDebugStringF)
{