@@ -372,6 +372,8 @@ ArgsManager::ArgsManager() :
372
372
373
373
void ArgsManager::WarnForSectionOnlyArgs ()
374
374
{
375
+ LOCK (cs_args);
376
+
375
377
// if there's no section selected, don't worry
376
378
if (m_network.empty ()) return ;
377
379
@@ -400,6 +402,7 @@ void ArgsManager::WarnForSectionOnlyArgs()
400
402
401
403
void ArgsManager::SelectConfigNetwork (const std::string& network)
402
404
{
405
+ LOCK (cs_args);
403
406
m_network = network;
404
407
}
405
408
@@ -468,6 +471,7 @@ bool ArgsManager::IsArgKnown(const std::string& key) const
468
471
arg_no_net = std::string (" -" ) + key.substr (option_index + 1 , std::string::npos);
469
472
}
470
473
474
+ LOCK (cs_args);
471
475
for (const auto & arg_map : m_available_args) {
472
476
if (arg_map.second .count (arg_no_net)) return true ;
473
477
}
@@ -571,6 +575,7 @@ void ArgsManager::AddArg(const std::string& name, const std::string& help, const
571
575
eq_index = name.size ();
572
576
}
573
577
578
+ LOCK (cs_args);
574
579
std::map<std::string, Arg>& arg_map = m_available_args[cat];
575
580
auto ret = arg_map.emplace (name.substr (0 , eq_index), Arg (name.substr (eq_index, name.size () - eq_index), help, debug_only));
576
581
assert (ret.second ); // Make sure an insertion actually happened
@@ -588,6 +593,7 @@ std::string ArgsManager::GetHelpMessage() const
588
593
const bool show_debug = gArgs .GetBoolArg (" -help-debug" , false );
589
594
590
595
std::string usage = " " ;
596
+ LOCK (cs_args);
591
597
for (const auto & arg_map : m_available_args) {
592
598
switch (arg_map.first ) {
593
599
case OptionsCategory::OPTIONS:
@@ -865,10 +871,8 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, std::string& error, boo
865
871
866
872
bool ArgsManager::ReadConfigFiles (std::string& error, bool ignore_invalid_keys)
867
873
{
868
- {
869
- LOCK (cs_args);
870
- m_config_args.clear ();
871
- }
874
+ LOCK (cs_args);
875
+ m_config_args.clear ();
872
876
873
877
const std::string confPath = GetArg (" -conf" , BITCOIN_CONF_FILENAME);
874
878
fs::ifstream stream (GetConfigFile (confPath));
@@ -892,11 +896,8 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
892
896
893
897
// Remove -includeconf from configuration, so we can warn about recursion
894
898
// later
895
- {
896
- LOCK (cs_args);
897
- m_config_args.erase (" -includeconf" );
898
- m_config_args.erase (std::string (" -" ) + chain_id + " .includeconf" );
899
- }
899
+ m_config_args.erase (" -includeconf" );
900
+ m_config_args.erase (std::string (" -" ) + chain_id + " .includeconf" );
900
901
901
902
for (const std::string& to_include : includeconf) {
902
903
fs::ifstream include_config (GetConfigFile (to_include));
@@ -940,6 +941,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
940
941
941
942
std::string ArgsManager::GetChainName () const
942
943
{
944
+ LOCK (cs_args);
943
945
bool fRegTest = ArgsManagerHelper::GetNetBoolArg (*this , " -regtest" );
944
946
bool fTestNet = ArgsManagerHelper::GetNetBoolArg (*this , " -testnet" );
945
947
0 commit comments