@@ -105,6 +105,7 @@ int64_t enforceMasternodePaymentsTime = 4085657524;
105105bool fSucessfullyLoaded = false ;
106106std::string strBudgetMode = " " ;
107107
108+ RecursiveMutex cs_args;
108109std::map<std::string, std::string> mapArgs;
109110static std::map<std::string, std::vector<std::string> > _mapMultiArgs;
110111const std::map<std::string, std::vector<std::string> >& mapMultiArgs = _mapMultiArgs;
@@ -182,6 +183,7 @@ static void InterpretNegativeSetting(std::string& strKey, std::string& strValue)
182183
183184void ParseParameters (int argc, const char * const argv[])
184185{
186+ LOCK (cs_args);
185187 mapArgs.clear ();
186188 _mapMultiArgs.clear ();
187189
@@ -215,32 +217,37 @@ void ParseParameters(int argc, const char* const argv[])
215217
216218bool IsArgSet (const std::string& strArg)
217219{
220+ LOCK (cs_args);
218221 return mapArgs.count (strArg);
219222}
220223
221224std::string GetArg (const std::string& strArg, const std::string& strDefault)
222225{
226+ LOCK (cs_args);
223227 if (mapArgs.count (strArg))
224228 return mapArgs[strArg];
225229 return strDefault;
226230}
227231
228232int64_t GetArg (const std::string& strArg, int64_t nDefault)
229233{
234+ LOCK (cs_args);
230235 if (mapArgs.count (strArg))
231236 return atoi64 (mapArgs[strArg]);
232237 return nDefault;
233238}
234239
235240bool GetBoolArg (const std::string& strArg, bool fDefault )
236241{
242+ LOCK (cs_args);
237243 if (mapArgs.count (strArg))
238244 return InterpretBool (mapArgs[strArg]);
239245 return fDefault ;
240246}
241247
242248bool SoftSetArg (const std::string& strArg, const std::string& strValue)
243249{
250+ LOCK (cs_args);
244251 if (mapArgs.count (strArg))
245252 return false ;
246253 mapArgs[strArg] = strValue;
@@ -452,6 +459,8 @@ const fs::path& GetDataDir(bool fNetSpecific)
452459
453460void ClearDatadirCache ()
454461{
462+ LOCK (csPathCached);
463+
455464 pathCached = fs::path ();
456465 pathCachedNetSpecific = fs::path ();
457466}
@@ -479,17 +488,20 @@ void ReadConfigFile()
479488 return ; // Nothing to read, so just return
480489 }
481490
482- std::set<std::string> setOptions;
483- setOptions.insert (" *" );
484-
485- for (boost::program_options::detail::config_file_iterator it (streamConfig, setOptions), end; it != end; ++it) {
486- // Don't overwrite existing settings so command line settings override pivx.conf
487- std::string strKey = std::string (" -" ) + it->string_key ;
488- std::string strValue = it->value [0 ];
489- InterpretNegativeSetting (strKey, strValue);
490- if (mapArgs.count (strKey) == 0 )
491- mapArgs[strKey] = strValue;
492- _mapMultiArgs[strKey].push_back (strValue);
491+ {
492+ LOCK (cs_args);
493+ std::set<std::string> setOptions;
494+ setOptions.insert (" *" );
495+
496+ for (boost::program_options::detail::config_file_iterator it (streamConfig, setOptions), end; it != end; ++it) {
497+ // Don't overwrite existing settings so command line settings override pivx.conf
498+ std::string strKey = std::string (" -" ) + it->string_key ;
499+ std::string strValue = it->value [0 ];
500+ InterpretNegativeSetting (strKey, strValue);
501+ if (mapArgs.count (strKey) == 0 )
502+ mapArgs[strKey] = strValue;
503+ _mapMultiArgs[strKey].push_back (strValue);
504+ }
493505 }
494506 // If datadir is changed in .conf file:
495507 ClearDatadirCache ();
0 commit comments