Fix potential deadlock
This commit is contained in:
parent
d58dc9f943
commit
1e29379d69
1 changed files with 15 additions and 5 deletions
20
src/util.cpp
20
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));
|
||||
|
|
Loading…
Reference in a new issue