Browse Source

Merge pull request #2608 from jonasschnelli/pathCacheFix

clear path cache after getting a proper config file (fixes #2605)
0.8
Pieter Wuille 12 years ago
parent
commit
b45fd0a5a4
  1. 9
      src/util.cpp

9
src/util.cpp

@ -83,6 +83,7 @@ bool fNoListen = false;
bool fLogTimestamps = false; bool fLogTimestamps = false;
CMedianFilter<int64> vTimeOffsets(200,0); CMedianFilter<int64> vTimeOffsets(200,0);
volatile bool fReopenDebugLog = false; volatile bool fReopenDebugLog = false;
bool fCachedPath[2] = {false, false};
// Init OpenSSL library multithreading support // Init OpenSSL library multithreading support
static CCriticalSection** ppmutexOpenSSL; static CCriticalSection** ppmutexOpenSSL;
@ -1048,13 +1049,12 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
static fs::path pathCached[2]; static fs::path pathCached[2];
static CCriticalSection csPathCached; static CCriticalSection csPathCached;
static bool cachedPath[2] = {false, false};
fs::path &path = pathCached[fNetSpecific]; fs::path &path = pathCached[fNetSpecific];
// This can be called during exceptions by printf, so we cache the // This can be called during exceptions by printf, so we cache the
// value so we don't have to do memory allocations after that. // value so we don't have to do memory allocations after that.
if (cachedPath[fNetSpecific]) if (fCachedPath[fNetSpecific])
return path; return path;
LOCK(csPathCached); LOCK(csPathCached);
@ -1073,7 +1073,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
fs::create_directory(path); fs::create_directory(path);
cachedPath[fNetSpecific] = true; fCachedPath[fNetSpecific] = true;
return path; return path;
} }
@ -1091,6 +1091,9 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
if (!streamConfig.good()) if (!streamConfig.good())
return; // No bitcoin.conf file is OK return; // No bitcoin.conf file is OK
// clear path cache after loading config file
fCachedPath[0] = fCachedPath[1] = false;
set<string> setOptions; set<string> setOptions;
setOptions.insert("*"); setOptions.insert("*");

Loading…
Cancel
Save