Fix potential deadlock

This commit is contained in:
practicalswift 2018-08-30 10:02:49 +02:00
parent d58dc9f943
commit 1e29379d69
1 changed files with 15 additions and 5 deletions

View File

@ -870,9 +870,11 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, std::string& error, boo
} }
bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys) bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
{
{ {
LOCK(cs_args); LOCK(cs_args);
m_config_args.clear(); m_config_args.clear();
}
const std::string confPath = GetArg("-conf", BITCOIN_CONF_FILENAME); const std::string confPath = GetArg("-conf", BITCOIN_CONF_FILENAME);
fs::ifstream stream(GetConfigFile(confPath)); 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 // 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 // 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::string chain_id = GetChainName();
std::vector<std::string> includeconf(GetArgs("-includeconf")); 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 // Remove -includeconf from configuration, so we can warn about recursion
// later // later
{
LOCK(cs_args);
m_config_args.erase("-includeconf"); m_config_args.erase("-includeconf");
m_config_args.erase(std::string("-") + chain_id + ".includeconf"); m_config_args.erase(std::string("-") + chain_id + ".includeconf");
}
for (const std::string& to_include : includeconf) { for (const std::string& to_include : includeconf) {
fs::ifstream include_config(GetConfigFile(to_include)); fs::ifstream include_config(GetConfigFile(to_include));