Make QT runawayException call GetWarnings instead of directly access strMiscWarning.
This is a first step in avoiding racy accesses to strMiscWarning. The change required moving GetWarnings and related globals to util.
This commit is contained in:
parent
2efcfa5acf
commit
c63198f1c7
5 changed files with 59 additions and 49 deletions
|
@ -260,7 +260,7 @@ BitcoinCore::BitcoinCore():
|
|||
void BitcoinCore::handleRunawayException(const std::exception *e)
|
||||
{
|
||||
PrintExceptionContinue(e, "Runaway exception");
|
||||
Q_EMIT runawayException(QString::fromStdString(strMiscWarning));
|
||||
Q_EMIT runawayException(QString::fromStdString(GetWarnings("gui")));
|
||||
}
|
||||
|
||||
void BitcoinCore::initialize()
|
||||
|
@ -691,10 +691,10 @@ int main(int argc, char *argv[])
|
|||
app.exec();
|
||||
} catch (const std::exception& e) {
|
||||
PrintExceptionContinue(&e, "Runaway exception");
|
||||
app.handleRunawayException(QString::fromStdString(strMiscWarning));
|
||||
app.handleRunawayException(QString::fromStdString(GetWarnings("gui")));
|
||||
} catch (...) {
|
||||
PrintExceptionContinue(NULL, "Runaway exception");
|
||||
app.handleRunawayException(QString::fromStdString(strMiscWarning));
|
||||
app.handleRunawayException(QString::fromStdString(GetWarnings("gui")));
|
||||
}
|
||||
return app.getReturnValue();
|
||||
}
|
||||
|
|
47
src/util.cpp
47
src/util.cpp
|
@ -107,7 +107,11 @@ map<string, vector<string> > mapMultiArgs;
|
|||
bool fDebug = false;
|
||||
bool fPrintToConsole = false;
|
||||
bool fPrintToDebugLog = true;
|
||||
|
||||
string strMiscWarning;
|
||||
bool fLargeWorkForkFound = false;
|
||||
bool fLargeWorkInvalidChainFound = false;
|
||||
|
||||
bool fLogTimestamps = DEFAULT_LOGTIMESTAMPS;
|
||||
bool fLogTimeMicros = DEFAULT_LOGTIMEMICROS;
|
||||
bool fLogIPs = DEFAULT_LOGIPS;
|
||||
|
@ -808,3 +812,46 @@ std::string CopyrightHolders(const std::string& strPrefix)
|
|||
}
|
||||
return strCopyrightHolders;
|
||||
}
|
||||
|
||||
std::string GetWarnings(const std::string& strFor)
|
||||
{
|
||||
string strStatusBar;
|
||||
string strRPC;
|
||||
string strGUI;
|
||||
const string uiAlertSeperator = "<hr />";
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
if (GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
|
||||
strStatusBar = strRPC = strGUI = "testsafemode enabled";
|
||||
|
||||
// Misc warnings like out of disk space and clock is wrong
|
||||
if (strMiscWarning != "")
|
||||
{
|
||||
strStatusBar = strMiscWarning;
|
||||
strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + strMiscWarning;
|
||||
}
|
||||
|
||||
if (fLargeWorkForkFound)
|
||||
{
|
||||
strStatusBar = strRPC = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
|
||||
strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
|
||||
}
|
||||
else if (fLargeWorkInvalidChainFound)
|
||||
{
|
||||
strStatusBar = strRPC = "Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.";
|
||||
strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
|
||||
}
|
||||
|
||||
if (strFor == "gui")
|
||||
return strGUI;
|
||||
else if (strFor == "statusbar")
|
||||
return strStatusBar;
|
||||
else if (strFor == "rpc")
|
||||
return strRPC;
|
||||
assert(!"GetWarnings(): invalid parameter");
|
||||
return "error";
|
||||
}
|
||||
|
|
|
@ -46,7 +46,12 @@ extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
|
|||
extern bool fDebug;
|
||||
extern bool fPrintToConsole;
|
||||
extern bool fPrintToDebugLog;
|
||||
|
||||
static const bool DEFAULT_TESTSAFEMODE = false;
|
||||
extern std::string strMiscWarning;
|
||||
extern bool fLargeWorkForkFound;
|
||||
extern bool fLargeWorkInvalidChainFound;
|
||||
|
||||
extern bool fLogTimestamps;
|
||||
extern bool fLogTimeMicros;
|
||||
extern bool fLogIPs;
|
||||
|
@ -224,4 +229,6 @@ template <typename Callable> void TraceThread(const char* name, Callable func)
|
|||
|
||||
std::string CopyrightHolders(const std::string& strPrefix);
|
||||
|
||||
std::string GetWarnings(const std::string& strFor);
|
||||
|
||||
#endif // BITCOIN_UTIL_H
|
||||
|
|
|
@ -1149,8 +1149,6 @@ bool IsInitialBlockDownload()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool fLargeWorkForkFound = false;
|
||||
bool fLargeWorkInvalidChainFound = false;
|
||||
CBlockIndex *pindexBestForkTip = NULL, *pindexBestForkBase = NULL;
|
||||
|
||||
static void AlertNotify(const std::string& strMessage)
|
||||
|
@ -4005,51 +4003,10 @@ void static CheckBlockIndex(const Consensus::Params& consensusParams)
|
|||
assert(nNodes == forward.size());
|
||||
}
|
||||
|
||||
std::string GetWarnings(const std::string& strFor)
|
||||
std::string CBlockFileInfo::ToString() const
|
||||
{
|
||||
string strStatusBar;
|
||||
string strRPC;
|
||||
string strGUI;
|
||||
const string uiAlertSeperator = "<hr />";
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
if (GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
|
||||
strStatusBar = strRPC = strGUI = "testsafemode enabled";
|
||||
|
||||
// Misc warnings like out of disk space and clock is wrong
|
||||
if (strMiscWarning != "")
|
||||
{
|
||||
strStatusBar = strMiscWarning;
|
||||
strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + strMiscWarning;
|
||||
}
|
||||
|
||||
if (fLargeWorkForkFound)
|
||||
{
|
||||
strStatusBar = strRPC = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
|
||||
strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
|
||||
}
|
||||
else if (fLargeWorkInvalidChainFound)
|
||||
{
|
||||
strStatusBar = strRPC = "Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.";
|
||||
strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
|
||||
}
|
||||
|
||||
if (strFor == "gui")
|
||||
return strGUI;
|
||||
else if (strFor == "statusbar")
|
||||
return strStatusBar;
|
||||
else if (strFor == "rpc")
|
||||
return strRPC;
|
||||
assert(!"GetWarnings(): invalid parameter");
|
||||
return "error";
|
||||
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, DateTimeStrFormat("%Y-%m-%d", nTimeFirst), DateTimeStrFormat("%Y-%m-%d", nTimeLast));
|
||||
}
|
||||
std::string CBlockFileInfo::ToString() const {
|
||||
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, DateTimeStrFormat("%Y-%m-%d", nTimeFirst), DateTimeStrFormat("%Y-%m-%d", nTimeLast));
|
||||
}
|
||||
|
||||
ThresholdState VersionBitsTipState(const Consensus::Params& params, Consensus::DeploymentPos pos)
|
||||
{
|
||||
|
|
|
@ -137,7 +137,6 @@ static const bool DEFAULT_CHECKPOINTS_ENABLED = true;
|
|||
static const bool DEFAULT_TXINDEX = false;
|
||||
static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100;
|
||||
|
||||
static const bool DEFAULT_TESTSAFEMODE = false;
|
||||
/** Default for -mempoolreplacement */
|
||||
static const bool DEFAULT_ENABLE_REPLACEMENT = true;
|
||||
/** Default for using fee filter */
|
||||
|
|
Loading…
Reference in a new issue