From e3ba0ef95636290a3bb597ddd25d13ea13b034aa Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Tue, 29 Nov 2016 09:46:19 +0000 Subject: Eliminate data races for strMiscWarning and fLargeWork*Found. This moves all access to these datastructures through accessor functions and protects them with a lock. --- src/util.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/util.cpp') diff --git a/src/util.cpp b/src/util.cpp index a2e6b85d29..92a5b34a3f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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 = "
"; + 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"); -- cgit v1.2.3