aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-06-17 09:09:12 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-06-19 09:38:04 +0200
commita3788527a2bb882106e2a57ce51fa6ddca527779 (patch)
treed9a4dfbebaf3a2d8a37f7b563f0357aeae4d1a45
parent9d5b5c3a2d273ae8be57592395e0d32bff63c56e (diff)
downloadbitcoin-a3788527a2bb882106e2a57ce51fa6ddca527779.tar.xz
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.
-rw-r--r--src/rpcserver.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp
index 4293deb157..205cbf2d79 100644
--- a/src/rpcserver.cpp
+++ b/src/rpcserver.cpp
@@ -639,11 +639,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();