mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
Merge pull request #4503
b45a6e8Add test for getblocktemplate longpolling (Wladimir J. van der Laan)ff6a7afgetblocktemplate: longpolling support (Luke Dashjr)
This commit is contained in:
@@ -32,6 +32,7 @@ using namespace std;
|
||||
|
||||
static std::string strRPCUserColonPass;
|
||||
|
||||
static bool fRPCRunning = false;
|
||||
// These are created by StartRPCThreads, destroyed in StopRPCThreads
|
||||
static asio::io_service* rpc_io_service = NULL;
|
||||
static map<string, boost::shared_ptr<deadline_timer> > deadlineTimers;
|
||||
@@ -659,6 +660,7 @@ void StartRPCThreads()
|
||||
rpc_worker_group = new boost::thread_group();
|
||||
for (int i = 0; i < GetArg("-rpcthreads", 4); i++)
|
||||
rpc_worker_group->create_thread(boost::bind(&asio::io_service::run, rpc_io_service));
|
||||
fRPCRunning = true;
|
||||
}
|
||||
|
||||
void StartDummyRPCThread()
|
||||
@@ -671,12 +673,15 @@ void StartDummyRPCThread()
|
||||
rpc_dummy_work = new asio::io_service::work(*rpc_io_service);
|
||||
rpc_worker_group = new boost::thread_group();
|
||||
rpc_worker_group->create_thread(boost::bind(&asio::io_service::run, rpc_io_service));
|
||||
fRPCRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
void StopRPCThreads()
|
||||
{
|
||||
if (rpc_io_service == NULL) return;
|
||||
// Set this to false first, so that longpolling loops will exit when woken up
|
||||
fRPCRunning = false;
|
||||
|
||||
// First, cancel all timers and acceptors
|
||||
// This is not done automatically by ->stop(), and in some cases the destructor of
|
||||
@@ -698,6 +703,7 @@ void StopRPCThreads()
|
||||
deadlineTimers.clear();
|
||||
|
||||
rpc_io_service->stop();
|
||||
cvBlockChange.notify_all();
|
||||
if (rpc_worker_group != NULL)
|
||||
rpc_worker_group->join_all();
|
||||
delete rpc_dummy_work; rpc_dummy_work = NULL;
|
||||
@@ -706,6 +712,11 @@ void StopRPCThreads()
|
||||
delete rpc_io_service; rpc_io_service = NULL;
|
||||
}
|
||||
|
||||
bool IsRPCRunning()
|
||||
{
|
||||
return fRPCRunning;
|
||||
}
|
||||
|
||||
void RPCRunHandler(const boost::system::error_code& err, boost::function<void(void)> func)
|
||||
{
|
||||
if (!err)
|
||||
|
||||
Reference in New Issue
Block a user