Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13711116
D5774.id18936.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D5774.id18936.diff
View Options
diff --git a/src/util/system.h b/src/util/system.h
--- a/src/util/system.h
+++ b/src/util/system.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2016 The Bitcoin Core developers
+// Copyright (c) 2009-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -26,13 +26,11 @@
#include <boost/thread/condition_variable.hpp> // for boost::thread_interrupted
-#include <atomic>
#include <cstdint>
#include <exception>
#include <map>
#include <set>
#include <string>
-#include <unordered_set>
#include <utility>
#include <vector>
@@ -85,6 +83,7 @@
// The blocks directory is always net specific.
const fs::path &GetBlocksDir();
const fs::path &GetDataDir(bool fNetSpecific = true);
+/** Tests only */
void ClearDatadirCache();
fs::path GetConfigFile(const std::string &confPath);
#ifndef WIN32
diff --git a/src/util/system.cpp b/src/util/system.cpp
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2016 The Bitcoin Core developers
+// Copyright (c) 2009-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -804,15 +804,14 @@
static fs::path g_blocks_path_cache_net_specific;
static fs::path pathCached;
static fs::path pathCachedNetSpecific;
-static CCriticalSection csPathCached;
+static RecursiveMutex csPathCached;
const fs::path &GetBlocksDir() {
LOCK(csPathCached);
-
fs::path &path = g_blocks_path_cache_net_specific;
- // This can be called during exceptions by LogPrintf(), so we cache the
- // value so we don't have to do memory allocations after that.
+ // Cache the path to avoid calling fs::create_directories on every call of
+ // this function
if (!path.empty()) {
return path;
}
@@ -835,11 +834,10 @@
const fs::path &GetDataDir(bool fNetSpecific) {
LOCK(csPathCached);
-
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.
+ // Cache the path to avoid calling fs::create_directories on every call of
+ // this function
if (!path.empty()) {
return path;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 26, 10:34 (3 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5573273
Default Alt Text
D5774.id18936.diff (2 KB)
Attached To
D5774: util: Explain why the path is cached
Event Timeline
Log In to Comment