From f297479a1995bd147c21c58fca103cd3ab3e54c1 Mon Sep 17 00:00:00 2001 From: jtimon Date: Mon, 1 Sep 2014 00:01:54 +0200 Subject: Reserve only one network specific cached path per session --- src/util.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/util.cpp') diff --git a/src/util.cpp b/src/util.cpp index 0ac0f70a7..7bb65f658 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -395,7 +395,7 @@ boost::filesystem::path GetDefaultDataDir() #endif } -static boost::filesystem::path pathCached[CBaseChainParams::MAX_NETWORK_TYPES+1]; +static boost::filesystem::path pathCached[2]; static CCriticalSection csPathCached; const boost::filesystem::path &GetDataDir(bool fNetSpecific) @@ -404,10 +404,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) LOCK(csPathCached); - int nNet = CBaseChainParams::MAX_NETWORK_TYPES; - if (fNetSpecific) nNet = BaseParams().NetworkID(); - - fs::path &path = pathCached[nNet]; + fs::path &path = pathCached[fNetSpecific ? 1 : 0]; // This can be called during exceptions by LogPrintf(), so we cache the // value so we don't have to do memory allocations after that. @@ -433,8 +430,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) void ClearDatadirCache() { - std::fill(&pathCached[0], &pathCached[CBaseChainParams::MAX_NETWORK_TYPES+1], - boost::filesystem::path()); + std::fill(&pathCached[0], &pathCached[2], boost::filesystem::path()); } boost::filesystem::path GetConfigFile() -- cgit v1.2.3 From ebdb9ff63992fe685688f6d47cd1f3a2938ee607 Mon Sep 17 00:00:00 2001 From: jtimon Date: Sat, 11 Oct 2014 20:56:27 +0200 Subject: SQUASHME: fix "Reserve only one network specific cached path per session" --- src/util.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/util.cpp') diff --git a/src/util.cpp b/src/util.cpp index 7bb65f658..ae7767a1f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -395,7 +395,8 @@ boost::filesystem::path GetDefaultDataDir() #endif } -static boost::filesystem::path pathCached[2]; +static boost::filesystem::path pathCached; +static boost::filesystem::path pathCachedNetSpecific; static CCriticalSection csPathCached; const boost::filesystem::path &GetDataDir(bool fNetSpecific) @@ -404,7 +405,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) LOCK(csPathCached); - fs::path &path = pathCached[fNetSpecific ? 1 : 0]; + fs::path &path = fNetSpecific ? pathCachedNetSpecific : pathCached; // This can be called during exceptions by LogPrintf(), so we cache the // value so we don't have to do memory allocations after that. @@ -430,7 +431,8 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) void ClearDatadirCache() { - std::fill(&pathCached[0], &pathCached[2], boost::filesystem::path()); + pathCached = boost::filesystem::path(); + pathCachedNetSpecific = boost::filesystem::path(); } boost::filesystem::path GetConfigFile() -- cgit v1.2.3