mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
rpc: Ignore and log errors during cancel
Cancelling the RPC acceptors can sometimes result in an error about a bad file descriptor. As this is the shutdown sequence we need to continue nevertheless, ignore these errors, log a warning and proceed. Fixes #4352.
This commit is contained in:
parent
9fe80a2ec8
commit
33e5b42910
@ -700,11 +700,20 @@ void StopRPCThreads()
|
|||||||
// First, cancel all timers and acceptors
|
// First, cancel all timers and acceptors
|
||||||
// This is not done automatically by ->stop(), and in some cases the destructor of
|
// This is not done automatically by ->stop(), and in some cases the destructor of
|
||||||
// asio::io_service can hang if this is skipped.
|
// asio::io_service can hang if this is skipped.
|
||||||
|
boost::system::error_code ec;
|
||||||
BOOST_FOREACH(const boost::shared_ptr<ip::tcp::acceptor> &acceptor, rpc_acceptors)
|
BOOST_FOREACH(const boost::shared_ptr<ip::tcp::acceptor> &acceptor, rpc_acceptors)
|
||||||
acceptor->cancel();
|
{
|
||||||
|
acceptor->cancel(ec);
|
||||||
|
if (ec)
|
||||||
|
LogPrintf("%s: Warning: %s when cancelling acceptor", __func__, ec.message());
|
||||||
|
}
|
||||||
rpc_acceptors.clear();
|
rpc_acceptors.clear();
|
||||||
BOOST_FOREACH(const PAIRTYPE(std::string, boost::shared_ptr<deadline_timer>) &timer, deadlineTimers)
|
BOOST_FOREACH(const PAIRTYPE(std::string, boost::shared_ptr<deadline_timer>) &timer, deadlineTimers)
|
||||||
timer.second->cancel();
|
{
|
||||||
|
timer.second->cancel(ec);
|
||||||
|
if (ec)
|
||||||
|
LogPrintf("%s: Warning: %s when cancelling timer", __func__, ec.message());
|
||||||
|
}
|
||||||
deadlineTimers.clear();
|
deadlineTimers.clear();
|
||||||
|
|
||||||
rpc_io_service->stop();
|
rpc_io_service->stop();
|
||||||
|
Loading…
Reference in New Issue
Block a user