RPC stop action can take a long time to close the node down (#2135)
* RPC stop action can take a long time to close node down * Formatting
This commit is contained in:
parent
e9c45bd234
commit
0b3f0f518a
3 changed files with 15 additions and 9 deletions
|
|
@ -133,8 +133,11 @@ void nano_daemon::daemon::run (boost::filesystem::path const & data_path, nano::
|
||||||
{
|
{
|
||||||
throw std::runtime_error ("Could not deserialize rpc_config file");
|
throw std::runtime_error ("Could not deserialize rpc_config file");
|
||||||
}
|
}
|
||||||
rpc_handler = std::make_unique<nano::inprocess_rpc_handler> (*node, config.rpc, [&ipc_server]() {
|
rpc_handler = std::make_unique<nano::inprocess_rpc_handler> (*node, config.rpc, [&ipc_server, &alarm, &io_ctx]() {
|
||||||
ipc_server.stop ();
|
ipc_server.stop ();
|
||||||
|
alarm.add (std::chrono::steady_clock::now () + std::chrono::seconds (3), [&io_ctx]() {
|
||||||
|
io_ctx.stop ();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
rpc = nano::get_rpc (io_ctx, rpc_config, *rpc_handler);
|
rpc = nano::get_rpc (io_ctx, rpc_config, *rpc_handler);
|
||||||
rpc->start ();
|
rpc->start ();
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,13 @@ void nano::confirmation_height_processor::add_confirmation_height (nano::block_h
|
||||||
collect_unconfirmed_receive_and_sources_for_account (block_height, iterated_height, current, account, read_transaction);
|
collect_unconfirmed_receive_and_sources_for_account (block_height, iterated_height, current, account, read_transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exit early when the processor has been stopped, otherwise this function may take a
|
||||||
|
// while (and hence keep the process running) if updating a long chain.
|
||||||
|
if (stopped)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// No longer need the read transaction
|
// No longer need the read transaction
|
||||||
read_transaction.reset ();
|
read_transaction.reset ();
|
||||||
|
|
||||||
|
|
@ -246,13 +253,6 @@ void nano::confirmation_height_processor::add_confirmation_height (nano::block_h
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exit early when the processor has been stopped, otherwise this function may take a
|
|
||||||
// while (and hence keep the process running) if updating a long chain.
|
|
||||||
if (stopped)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
read_transaction.renew ();
|
read_transaction.renew ();
|
||||||
} while (!receive_source_pairs.empty () || current != hash_a);
|
} while (!receive_source_pairs.empty () || current != hash_a);
|
||||||
}
|
}
|
||||||
|
|
@ -328,7 +328,7 @@ void nano::confirmation_height_processor::collect_unconfirmed_receive_and_source
|
||||||
// Store heights of blocks
|
// Store heights of blocks
|
||||||
constexpr auto height_not_set = std::numeric_limits<uint64_t>::max ();
|
constexpr auto height_not_set = std::numeric_limits<uint64_t>::max ();
|
||||||
auto next_height = height_not_set;
|
auto next_height = height_not_set;
|
||||||
while ((num_to_confirm > 0) && !hash.is_zero ())
|
while ((num_to_confirm > 0) && !hash.is_zero () && !stopped)
|
||||||
{
|
{
|
||||||
nano::block_sideband sideband;
|
nano::block_sideband sideband;
|
||||||
auto block (store.block_get (transaction_a, hash, &sideband));
|
auto block (store.block_get (transaction_a, hash, &sideband));
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,9 @@ public:
|
||||||
// Note that if the rpc action is async, the shared_ptr<json_handler> lifetime will be extended by the action handler
|
// Note that if the rpc action is async, the shared_ptr<json_handler> lifetime will be extended by the action handler
|
||||||
auto handler (std::make_shared<nano::json_handler> (node, server.node_rpc_config, body, response_handler_l, [& server = server]() {
|
auto handler (std::make_shared<nano::json_handler> (node, server.node_rpc_config, body, response_handler_l, [& server = server]() {
|
||||||
server.stop ();
|
server.stop ();
|
||||||
|
server.node.alarm.add (std::chrono::steady_clock::now () + std::chrono::seconds (3), [& io_ctx = server.node.alarm.io_ctx]() {
|
||||||
|
io_ctx.stop ();
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
// For unsafe actions to be allowed, the unsafe encoding must be used AND the transport config must allow it
|
// For unsafe actions to be allowed, the unsafe encoding must be used AND the transport config must allow it
|
||||||
handler->process_request (allow_unsafe && config_transport.allow_unsafe);
|
handler->process_request (allow_unsafe && config_transport.allow_unsafe);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue