Add missing locks (cs_args)
This commit is contained in:
parent
4e9a6f87b7
commit
db5e9d3c88
2 changed files with 15 additions and 10 deletions
20
src/util.cpp
20
src/util.cpp
|
@ -372,6 +372,8 @@ ArgsManager::ArgsManager() :
|
|||
|
||||
void ArgsManager::WarnForSectionOnlyArgs()
|
||||
{
|
||||
LOCK(cs_args);
|
||||
|
||||
// if there's no section selected, don't worry
|
||||
if (m_network.empty()) return;
|
||||
|
||||
|
@ -400,6 +402,7 @@ void ArgsManager::WarnForSectionOnlyArgs()
|
|||
|
||||
void ArgsManager::SelectConfigNetwork(const std::string& network)
|
||||
{
|
||||
LOCK(cs_args);
|
||||
m_network = network;
|
||||
}
|
||||
|
||||
|
@ -468,6 +471,7 @@ bool ArgsManager::IsArgKnown(const std::string& key) const
|
|||
arg_no_net = std::string("-") + key.substr(option_index + 1, std::string::npos);
|
||||
}
|
||||
|
||||
LOCK(cs_args);
|
||||
for (const auto& arg_map : m_available_args) {
|
||||
if (arg_map.second.count(arg_no_net)) return true;
|
||||
}
|
||||
|
@ -571,6 +575,7 @@ void ArgsManager::AddArg(const std::string& name, const std::string& help, const
|
|||
eq_index = name.size();
|
||||
}
|
||||
|
||||
LOCK(cs_args);
|
||||
std::map<std::string, Arg>& arg_map = m_available_args[cat];
|
||||
auto ret = arg_map.emplace(name.substr(0, eq_index), Arg(name.substr(eq_index, name.size() - eq_index), help, debug_only));
|
||||
assert(ret.second); // Make sure an insertion actually happened
|
||||
|
@ -588,6 +593,7 @@ std::string ArgsManager::GetHelpMessage() const
|
|||
const bool show_debug = gArgs.GetBoolArg("-help-debug", false);
|
||||
|
||||
std::string usage = "";
|
||||
LOCK(cs_args);
|
||||
for (const auto& arg_map : m_available_args) {
|
||||
switch(arg_map.first) {
|
||||
case OptionsCategory::OPTIONS:
|
||||
|
@ -865,10 +871,8 @@ 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));
|
||||
|
@ -892,11 +896,8 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
|||
|
||||
// Remove -includeconf from configuration, so we can warn about recursion
|
||||
// later
|
||||
{
|
||||
LOCK(cs_args);
|
||||
m_config_args.erase("-includeconf");
|
||||
m_config_args.erase(std::string("-") + chain_id + ".includeconf");
|
||||
}
|
||||
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));
|
||||
|
@ -940,6 +941,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
|||
|
||||
std::string ArgsManager::GetChainName() const
|
||||
{
|
||||
LOCK(cs_args);
|
||||
bool fRegTest = ArgsManagerHelper::GetNetBoolArg(*this, "-regtest");
|
||||
bool fTestNet = ArgsManagerHelper::GetNetBoolArg(*this, "-testnet");
|
||||
|
||||
|
|
|
@ -262,7 +262,10 @@ public:
|
|||
/**
|
||||
* Clear available arguments
|
||||
*/
|
||||
void ClearArgs() { m_available_args.clear(); }
|
||||
void ClearArgs() {
|
||||
LOCK(cs_args);
|
||||
m_available_args.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the help string
|
||||
|
|
Loading…
Reference in a new issue