Skip to content

Commit

Permalink
rpc: Ignore and log errors during cancel
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
laanwj committed Jun 19, 2014
1 parent 9fe80a2 commit 33e5b42
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/rpcserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 33e5b42

Please sign in to comment.