mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-08 11:44:14 +01:00
Merge #18452: qt: Fix shutdown when waitfor* cmds are called from RPC console
da73f1513aqt: Fix shutdown when waitfor* cmds are called from RPC console (Hennadii Stepanov) Pull request description: On master (7eed413e72), if the GUI has been started with`-server=1`, `bitcoin-qt` hangs on shutdown during calling any of the `waitfor*` commands in the GUI RPC console. This PR suggests minimal changes to fix this bug. Fix #17495 ACKs for top commit: jonasschnelli: utACKda73f1513aTree-SHA512: 469f5332945a5f2c57d19336cda5df79b123ccc494aea6d58a85eb1293be52708b2b9c5bb6bc2c402a90b7b4e9e8d7ab8fe84cf201cf7ce612c9290c57e43681
This commit is contained in:
@@ -15,11 +15,15 @@
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/signals2/signal.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <memory> // for unique_ptr
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
static RecursiveMutex cs_rpcWarmup;
|
||||
static std::atomic<bool> g_rpc_running{false};
|
||||
static std::once_flag g_rpc_interrupt_flag;
|
||||
static std::once_flag g_rpc_stop_flag;
|
||||
static bool fRPCInWarmup GUARDED_BY(cs_rpcWarmup) = true;
|
||||
static std::string rpcWarmupStatus GUARDED_BY(cs_rpcWarmup) = "RPC server started";
|
||||
/* Timer-creating functions */
|
||||
@@ -291,17 +295,24 @@ void StartRPC()
|
||||
|
||||
void InterruptRPC()
|
||||
{
|
||||
LogPrint(BCLog::RPC, "Interrupting RPC\n");
|
||||
// Interrupt e.g. running longpolls
|
||||
g_rpc_running = false;
|
||||
// This function could be called twice if the GUI has been started with -server=1.
|
||||
std::call_once(g_rpc_interrupt_flag, []() {
|
||||
LogPrint(BCLog::RPC, "Interrupting RPC\n");
|
||||
// Interrupt e.g. running longpolls
|
||||
g_rpc_running = false;
|
||||
});
|
||||
}
|
||||
|
||||
void StopRPC()
|
||||
{
|
||||
LogPrint(BCLog::RPC, "Stopping RPC\n");
|
||||
WITH_LOCK(g_deadline_timers_mutex, deadlineTimers.clear());
|
||||
DeleteAuthCookie();
|
||||
g_rpcSignals.Stopped();
|
||||
// This function could be called twice if the GUI has been started with -server=1.
|
||||
assert(!g_rpc_running);
|
||||
std::call_once(g_rpc_stop_flag, []() {
|
||||
LogPrint(BCLog::RPC, "Stopping RPC\n");
|
||||
WITH_LOCK(g_deadline_timers_mutex, deadlineTimers.clear());
|
||||
DeleteAuthCookie();
|
||||
g_rpcSignals.Stopped();
|
||||
});
|
||||
}
|
||||
|
||||
bool IsRPCRunning()
|
||||
|
||||
Reference in New Issue
Block a user