Skip to content

Commit

Permalink
boost: drop boost threads for [alert|block|wallet]notify
Browse files Browse the repository at this point in the history
Cherry-picked from: 004f999
  • Loading branch information
theuni authored and xanimo committed Mar 29, 2024
1 parent 21f5085 commit 2a2f6e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#include <boost/bind/bind.hpp>
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/thread.hpp>
#include <thread>
#include <openssl/crypto.h>

#if ENABLE_ZMQ
Expand Down Expand Up @@ -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<std::string>(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<std::string>(pBlockIndex->nHeight));
std::thread t(runCommand, strCmd);
t.detach(); // thread runs free
}
}

static bool fHaveGenesis = false;
Expand Down
3 changes: 2 additions & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include <boost/algorithm/string/replace.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/thread.hpp>
#include <thread>

using namespace std;

Expand Down Expand Up @@ -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<std::string>(nHeight));
boost::thread t(runCommand, strCmd); // thread runs free
std::thread t(runCommand, strCmd);
t.detach(); // thread runs free
}

return true;
Expand Down

0 comments on commit 2a2f6e6

Please sign in to comment.