Eliminate data races for strMiscWarning and fLargeWork*Found.

This moves all access to these datastructures through accessor functions
 and protects them with a lock.
This commit is contained in:
Gregory Maxwell
2016-11-29 09:46:19 +00:00
parent c63198f1c7
commit e3ba0ef956
4 changed files with 53 additions and 16 deletions

View File

@@ -108,6 +108,7 @@ bool fDebug = false;
bool fPrintToConsole = false;
bool fPrintToDebugLog = true;
CCriticalSection cs_warnings;
string strMiscWarning;
bool fLargeWorkForkFound = false;
bool fLargeWorkInvalidChainFound = false;
@@ -813,6 +814,36 @@ std::string CopyrightHolders(const std::string& strPrefix)
return strCopyrightHolders;
}
void SetMiscWarning(const std::string& strWarning)
{
LOCK(cs_warnings);
strMiscWarning = strWarning;
}
void SetfLargeWorkForkFound(bool flag)
{
LOCK(cs_warnings);
fLargeWorkForkFound = flag;
}
bool GetfLargeWorkForkFound()
{
LOCK(cs_warnings);
return fLargeWorkForkFound;
}
void SetfLargeWorkInvalidChainFound(bool flag)
{
LOCK(cs_warnings);
fLargeWorkInvalidChainFound = flag;
}
bool GetfLargeWorkInvalidChainFound()
{
LOCK(cs_warnings);
return fLargeWorkInvalidChainFound;
}
std::string GetWarnings(const std::string& strFor)
{
string strStatusBar;
@@ -820,6 +851,8 @@ std::string GetWarnings(const std::string& strFor)
string strGUI;
const string uiAlertSeperator = "<hr />";
LOCK(cs_warnings);
if (!CLIENT_VERSION_IS_RELEASE) {
strStatusBar = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");