From 2a2f6e6ce3dfc1de06e99a56bf7695ab894c754e Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Wed, 7 Feb 2018 19:19:34 -0500 Subject: [PATCH] boost: drop boost threads for [alert|block|wallet]notify Cherry-picked from: 004f9999464c7ef4a57b281dcbb407e5d193e798 --- src/init.cpp | 12 +++++++----- src/validation.cpp | 3 ++- src/wallet/wallet.cpp | 5 +++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 0b021064790..ebbd5495d14 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -60,7 +60,7 @@ #include #include #include -#include +#include #include #if ENABLE_ZMQ @@ -544,10 +544,12 @@ static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex return; std::string strCmd = GetArg("-blocknotify", ""); - - boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex()); - boost::replace_all(strCmd, "%i", boost::lexical_cast(pBlockIndex->nHeight)); - boost::thread t(runCommand, strCmd); // thread runs free + if (!strCmd.empty()) { + boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex()); + boost::replace_all(strCmd, "%i", boost::lexical_cast(pBlockIndex->nHeight)); + std::thread t(runCommand, strCmd); + t.detach(); // thread runs free + } } static bool fHaveGenesis = false; diff --git a/src/validation.cpp b/src/validation.cpp index a3f55de2328..25a546193f9 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1259,7 +1259,8 @@ static void AlertNotify(const std::string& strMessage) safeStatus = singleQuote+safeStatus+singleQuote; boost::replace_all(strCmd, "%s", safeStatus); - boost::thread t(runCommand, strCmd); // thread runs free + std::thread t(runCommand, strCmd); + t.detach(); // thread runs free } void CheckForkWarningConditions() diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 09d50651cbd..be4bd1dbf8c 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -34,7 +34,7 @@ #include #include -#include +#include using namespace std; @@ -1001,7 +1001,8 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose) int64_t nHeight = wtxIn.hashUnset() ? 0 : mapBlockIndex[wtxIn.hashBlock]->nHeight; boost::replace_all(strCmd, "%s", wtxIn.GetHash().GetHex()); boost::replace_all(strCmd, "%i", boost::lexical_cast(nHeight)); - boost::thread t(runCommand, strCmd); // thread runs free + std::thread t(runCommand, strCmd); + t.detach(); // thread runs free } return true;