diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-06-17 09:09:12 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-06-19 08:19:46 +0200 |
commit | 33e5b4291036bbdad075f4a549491af72d8a0618 (patch) | |
tree | 6b36774d710fc8f0bdcc94a576f6586b3f06836e /src | |
parent | 9fe80a2ec8f1578123a4cf946af512f310a34419 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/rpcserver.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index d4ceb7f995..2f7f5cc2ad 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -700,11 +700,20 @@ void StopRPCThreads() // First, cancel all timers and acceptors // This is not done automatically by ->stop(), and in some cases the destructor of // 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) - acceptor->cancel(); + { + acceptor->cancel(ec); + if (ec) + LogPrintf("%s: Warning: %s when cancelling acceptor", __func__, ec.message()); + } rpc_acceptors.clear(); 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(); rpc_io_service->stop(); |