Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/server.cpp
Show All 20 Lines | |||||
#include <boost/algorithm/string/classification.hpp> | #include <boost/algorithm/string/classification.hpp> | ||||
#include <boost/algorithm/string/split.hpp> | #include <boost/algorithm/string/split.hpp> | ||||
#include <boost/signals2/signal.hpp> | #include <boost/signals2/signal.hpp> | ||||
#include <memory> // for unique_ptr | #include <memory> // for unique_ptr | ||||
#include <set> | #include <set> | ||||
#include <unordered_map> | #include <unordered_map> | ||||
static bool fRPCRunning = false; | static std::atomic<bool> g_rpc_running{false}; | ||||
static bool fRPCInWarmup = true; | static bool fRPCInWarmup = true; | ||||
static std::string rpcWarmupStatus("RPC server started"); | static std::string rpcWarmupStatus("RPC server started"); | ||||
static CCriticalSection cs_rpcWarmup; | static CCriticalSection cs_rpcWarmup; | ||||
/* Timer-creating functions */ | /* Timer-creating functions */ | ||||
static RPCTimerInterface *timerInterface = nullptr; | static RPCTimerInterface *timerInterface = nullptr; | ||||
/* Map of name to timer. */ | /* Map of name to timer. */ | ||||
static std::map<std::string, std::unique_ptr<RPCTimerBase>> deadlineTimers; | static std::map<std::string, std::unique_ptr<RPCTimerBase>> deadlineTimers; | ||||
▲ Show 20 Lines • Show All 380 Lines • ▼ Show 20 Lines | bool CRPCTable::appendCommand(const std::string &name, | ||||
} | } | ||||
mapCommands[name] = pcmd; | mapCommands[name] = pcmd; | ||||
return true; | return true; | ||||
} | } | ||||
void StartRPC() { | void StartRPC() { | ||||
LogPrint(BCLog::RPC, "Starting RPC\n"); | LogPrint(BCLog::RPC, "Starting RPC\n"); | ||||
fRPCRunning = true; | g_rpc_running = true; | ||||
g_rpcSignals.Started(); | g_rpcSignals.Started(); | ||||
} | } | ||||
void InterruptRPC() { | void InterruptRPC() { | ||||
LogPrint(BCLog::RPC, "Interrupting RPC\n"); | LogPrint(BCLog::RPC, "Interrupting RPC\n"); | ||||
// Interrupt e.g. running longpolls | // Interrupt e.g. running longpolls | ||||
fRPCRunning = false; | g_rpc_running = false; | ||||
} | } | ||||
void StopRPC() { | void StopRPC() { | ||||
LogPrint(BCLog::RPC, "Stopping RPC\n"); | LogPrint(BCLog::RPC, "Stopping RPC\n"); | ||||
deadlineTimers.clear(); | deadlineTimers.clear(); | ||||
DeleteAuthCookie(); | DeleteAuthCookie(); | ||||
g_rpcSignals.Stopped(); | g_rpcSignals.Stopped(); | ||||
} | } | ||||
bool IsRPCRunning() { | bool IsRPCRunning() { | ||||
return fRPCRunning; | return g_rpc_running; | ||||
} | } | ||||
void SetRPCWarmupStatus(const std::string &newStatus) { | void SetRPCWarmupStatus(const std::string &newStatus) { | ||||
LOCK(cs_rpcWarmup); | LOCK(cs_rpcWarmup); | ||||
rpcWarmupStatus = newStatus; | rpcWarmupStatus = newStatus; | ||||
} | } | ||||
void SetRPCWarmupFinished() { | void SetRPCWarmupFinished() { | ||||
▲ Show 20 Lines • Show All 191 Lines • Show Last 20 Lines |