@@ -216,7 +216,7 @@ class ArgsManagerHelper {
216
216
217
217
/* * Determine whether to use config settings in the default section,
218
218
* See also comments around ArgsManager::ArgsManager() below. */
219
- static inline bool UseDefaultSection (const ArgsManager& am, const std::string& arg)
219
+ static inline bool UseDefaultSection (const ArgsManager& am, const std::string& arg) EXCLUSIVE_LOCKS_REQUIRED(am.cs_args)
220
220
{
221
221
return (am.m_network == CBaseChainParams::MAIN || am.m_network_only_args .count (arg) == 0 );
222
222
}
@@ -295,7 +295,7 @@ class ArgsManagerHelper {
295
295
/* Special test for -testnet and -regtest args, because we
296
296
* don't want to be confused by craziness like "[regtest] testnet=1"
297
297
*/
298
- static inline bool GetNetBoolArg (const ArgsManager &am, const std::string& net_arg)
298
+ static inline bool GetNetBoolArg (const ArgsManager &am, const std::string& net_arg) EXCLUSIVE_LOCKS_REQUIRED(am.cs_args)
299
299
{
300
300
std::pair<bool ,std::string> found_result (false ,std::string ());
301
301
found_result = GetArgHelper (am.m_override_args , net_arg, true );
@@ -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:
@@ -880,7 +886,12 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
880
886
}
881
887
// if there is an -includeconf in the override args, but it is empty, that means the user
882
888
// passed '-noincludeconf' on the command line, in which case we should not include anything
883
- if (m_override_args.count (" -includeconf" ) == 0 ) {
889
+ bool emptyIncludeConf;
890
+ {
891
+ LOCK (cs_args);
892
+ emptyIncludeConf = m_override_args.count (" -includeconf" ) == 0 ;
893
+ }
894
+ if (emptyIncludeConf) {
884
895
std::string chain_id = GetChainName ();
885
896
std::vector<std::string> includeconf (GetArgs (" -includeconf" ));
886
897
{
@@ -940,6 +951,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
940
951
941
952
std::string ArgsManager::GetChainName () const
942
953
{
954
+ LOCK (cs_args);
943
955
bool fRegTest = ArgsManagerHelper::GetNetBoolArg (*this , " -regtest" );
944
956
bool fTestNet = ArgsManagerHelper::GetNetBoolArg (*this , " -testnet" );
945
957
0 commit comments