aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2018-08-30 10:02:49 +0200
committerpracticalswift <practicalswift@users.noreply.github.com>2018-08-30 10:02:49 +0200
commit1e29379d69a6db0820ae984733d1be98340e5ed0 (patch)
tree9fc5d4028546458e35d172e2fec3372bb4b52f54 /src
parentd58dc9f94365ba3f993594bab293915d79dbe117 (diff)
Fix potential deadlock
Diffstat (limited to 'src')
-rw-r--r--src/util.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/util.cpp b/src/util.cpp
index e58ff042e8..3bb52e9b3d 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -871,8 +871,10 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, std::string& error, boo
bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
{
- LOCK(cs_args);
- m_config_args.clear();
+ {
+ LOCK(cs_args);
+ m_config_args.clear();
+ }
const std::string confPath = GetArg("-conf", BITCOIN_CONF_FILENAME);
fs::ifstream stream(GetConfigFile(confPath));
@@ -884,7 +886,12 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
}
// if there is an -includeconf in the override args, but it is empty, that means the user
// passed '-noincludeconf' on the command line, in which case we should not include anything
- if (m_override_args.count("-includeconf") == 0) {
+ bool emptyIncludeConf;
+ {
+ LOCK(cs_args);
+ emptyIncludeConf = m_override_args.count("-includeconf") == 0;
+ }
+ if (emptyIncludeConf) {
std::string chain_id = GetChainName();
std::vector<std::string> includeconf(GetArgs("-includeconf"));
{
@@ -896,8 +903,11 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
// Remove -includeconf from configuration, so we can warn about recursion
// later
- m_config_args.erase("-includeconf");
- m_config_args.erase(std::string("-") + chain_id + ".includeconf");
+ {
+ LOCK(cs_args);
+ m_config_args.erase("-includeconf");
+ m_config_args.erase(std::string("-") + chain_id + ".includeconf");
+ }
for (const std::string& to_include : includeconf) {
fs::ifstream include_config(GetConfigFile(to_include));