@@ -102,6 +102,7 @@ using namespace std;
102
102
const char * const BITCOIN_CONF_FILENAME = " bitcoin.conf" ;
103
103
const char * const BITCOIN_PID_FILENAME = " bitcoind.pid" ;
104
104
105
+ CCriticalSection cs_args;
105
106
map<string, string> mapArgs;
106
107
static map<string, vector<string> > _mapMultiArgs;
107
108
const map<string, vector<string> >& mapMultiArgs = _mapMultiArgs;
@@ -346,6 +347,7 @@ static void InterpretNegativeSetting(std::string& strKey, std::string& strValue)
346
347
347
348
void ParseParameters (int argc, const char * const argv[])
348
349
{
350
+ LOCK (cs_args);
349
351
mapArgs.clear ();
350
352
_mapMultiArgs.clear ();
351
353
@@ -381,32 +383,37 @@ void ParseParameters(int argc, const char* const argv[])
381
383
382
384
bool IsArgSet (const std::string& strArg)
383
385
{
386
+ LOCK (cs_args);
384
387
return mapArgs.count (strArg);
385
388
}
386
389
387
390
std::string GetArg (const std::string& strArg, const std::string& strDefault)
388
391
{
392
+ LOCK (cs_args);
389
393
if (mapArgs.count (strArg))
390
394
return mapArgs[strArg];
391
395
return strDefault;
392
396
}
393
397
394
398
int64_t GetArg (const std::string& strArg, int64_t nDefault)
395
399
{
400
+ LOCK (cs_args);
396
401
if (mapArgs.count (strArg))
397
402
return atoi64 (mapArgs[strArg]);
398
403
return nDefault;
399
404
}
400
405
401
406
bool GetBoolArg (const std::string& strArg, bool fDefault )
402
407
{
408
+ LOCK (cs_args);
403
409
if (mapArgs.count (strArg))
404
410
return InterpretBool (mapArgs[strArg]);
405
411
return fDefault ;
406
412
}
407
413
408
414
bool SoftSetArg (const std::string& strArg, const std::string& strValue)
409
415
{
416
+ LOCK (cs_args);
410
417
if (mapArgs.count (strArg))
411
418
return false ;
412
419
mapArgs[strArg] = strValue;
@@ -522,6 +529,8 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
522
529
523
530
void ClearDatadirCache ()
524
531
{
532
+ LOCK (csPathCached);
533
+
525
534
pathCached = boost::filesystem::path ();
526
535
pathCachedNetSpecific = boost::filesystem::path ();
527
536
}
@@ -541,18 +550,21 @@ void ReadConfigFile(const std::string& confPath)
541
550
if (!streamConfig.good ())
542
551
return ; // No bitcoin.conf file is OK
543
552
544
- set<string> setOptions;
545
- setOptions.insert (" *" );
546
-
547
- for (boost::program_options::detail::config_file_iterator it (streamConfig, setOptions), end; it != end; ++it)
548
553
{
549
- // Don't overwrite existing settings so command line settings override bitcoin.conf
550
- string strKey = string (" -" ) + it->string_key ;
551
- string strValue = it->value [0 ];
552
- InterpretNegativeSetting (strKey, strValue);
553
- if (mapArgs.count (strKey) == 0 )
554
- mapArgs[strKey] = strValue;
555
- _mapMultiArgs[strKey].push_back (strValue);
554
+ LOCK (cs_args);
555
+ set<string> setOptions;
556
+ setOptions.insert (" *" );
557
+
558
+ for (boost::program_options::detail::config_file_iterator it (streamConfig, setOptions), end; it != end; ++it)
559
+ {
560
+ // Don't overwrite existing settings so command line settings override bitcoin.conf
561
+ string strKey = string (" -" ) + it->string_key ;
562
+ string strValue = it->value [0 ];
563
+ InterpretNegativeSetting (strKey, strValue);
564
+ if (mapArgs.count (strKey) == 0 )
565
+ mapArgs[strKey] = strValue;
566
+ _mapMultiArgs[strKey].push_back (strValue);
567
+ }
556
568
}
557
569
// If datadir is changed in .conf file:
558
570
ClearDatadirCache ();
0 commit comments