Skip to content

Commit

Permalink
clear path cache after getting a proper config file (fixes #2605)
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Schnelli <[email protected]>
  • Loading branch information
jonasschnelli committed May 2, 2013
1 parent eef2091 commit b357a71
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ bool fNoListen = false;
bool fLogTimestamps = false;
CMedianFilter<int64> vTimeOffsets(200,0);
volatile bool fReopenDebugLog = false;
bool fCachedPath[2] = {false, false};

// Init OpenSSL library multithreading support
static CCriticalSection** ppmutexOpenSSL;
Expand Down Expand Up @@ -1048,13 +1049,12 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)

static fs::path pathCached[2];
static CCriticalSection csPathCached;
static bool cachedPath[2] = {false, false};

fs::path &path = pathCached[fNetSpecific];

// This can be called during exceptions by printf, so we cache the
// value so we don't have to do memory allocations after that.
if (cachedPath[fNetSpecific])
if (fCachedPath[fNetSpecific])
return path;

LOCK(csPathCached);
Expand All @@ -1073,7 +1073,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)

fs::create_directory(path);

cachedPath[fNetSpecific] = true;
fCachedPath[fNetSpecific] = true;
return path;
}

Expand All @@ -1091,6 +1091,9 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
if (!streamConfig.good())
return; // No bitcoin.conf file is OK

// clear path cache after loading config file
fCachedPath[0] = fCachedPath[1] = false;

set<string> setOptions;
setOptions.insert("*");

Expand Down

0 comments on commit b357a71

Please sign in to comment.