potentially add a shutting_down bool to the c++ layer.

This commit is contained in:
Christopher Jeffrey 2014-12-12 11:03:53 -08:00
parent f552121fb2
commit ece3d65cc5

View File

@ -420,6 +420,7 @@ init(Handle<Object>);
*/ */
static volatile bool shutdown_complete = false; static volatile bool shutdown_complete = false;
static volatile bool shutting_down = false;
static char *g_data_dir = NULL; static char *g_data_dir = NULL;
static bool g_rpc = false; static bool g_rpc = false;
static bool g_testnet = false; static bool g_testnet = false;
@ -904,6 +905,8 @@ start_node_thread(void) {
; ;
} }
shutting_down = true;
if (!fRet) { if (!fRet) {
if (detectShutdownThread) { if (detectShutdownThread) {
detectShutdownThread->interrupt(); detectShutdownThread->interrupt();
@ -968,6 +971,7 @@ NAN_METHOD(StopBitcoind) {
static void static void
async_stop_node(uv_work_t *req) { async_stop_node(uv_work_t *req) {
async_node_data *data = static_cast<async_node_data*>(req->data); async_node_data *data = static_cast<async_node_data*>(req->data);
shutting_down = true;
unhook_packets(); unhook_packets();
StartShutdown(); StartShutdown();
data->result = std::string("bitcoind shutdown."); data->result = std::string("bitcoind shutdown.");
@ -1044,6 +1048,8 @@ NAN_METHOD(IsStopped) {
NAN_METHOD(GetBlock) { NAN_METHOD(GetBlock) {
NanScope(); NanScope();
// if (shutting_down) NanReturnValue(Undefined());
if (args.Length() < 2 if (args.Length() < 2
|| (!args[0]->IsString() && !args[0]->IsNumber()) || (!args[0]->IsString() && !args[0]->IsNumber())
|| !args[1]->IsFunction()) { || !args[1]->IsFunction()) {