Mercurial > hg > bitcoin
changeset 300:015d5de83339 draft
Re-open debug.log every ten minutes instead of every printf; fixes performance problem with Mac FileVault.
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@181 1a98c847-1fd6-4fd8-948a-caf3550aa51b
author | gavinandresen <gavinandresen@1a98c847-1fd6-4fd8-948a-caf3550aa51b> |
---|---|
date | Tue, 16 Nov 2010 02:32:36 +0000 (2010-11-16) |
parents | 0c2b6f1b1fc0 |
children | 55442696faa0 41663c6d1fd9 |
files | util.cpp |
diffstat | 1 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/util.cpp +++ b/util.cpp @@ -157,10 +157,19 @@ else { // print to debug.log - char pszFile[MAX_PATH+100]; - GetDataDir(pszFile); - strlcat(pszFile, "/debug.log", sizeof(pszFile)); - FILE* fileout = fopen(pszFile, "a"); + static FILE* fileout = NULL; + static int64 nOpenTime = 0; + + 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 @@ -169,7 +178,7 @@ va_start(arg_ptr, pszFormat); ret = vfprintf(fileout, pszFormat, arg_ptr); va_end(arg_ptr); - fclose(fileout); + fflush(fileout); } }