@@ -642,7 +642,6 @@ void StartRPCThreads()
642642 LogPrintf (" Binding RPC on address %s port %i (IPv4+IPv6 bind any: %i)\n " , bindAddress.to_string (), endpoint.port (), bBindAny);
643643 boost::system::error_code v6_only_error;
644644 boost::shared_ptr<ip::tcp::acceptor> acceptor (new ip::tcp::acceptor (*rpc_io_service));
645- rpc_acceptors.push_back (acceptor);
646645
647646 try {
648647 acceptor->open (endpoint.protocol ());
@@ -658,6 +657,7 @@ void StartRPCThreads()
658657 RPCListen (acceptor, *rpc_ssl_context, fUseSSL );
659658
660659 fListening = true ;
660+ rpc_acceptors.push_back (acceptor);
661661 // If dual IPv6/IPv4 bind succesful, skip binding to IPv4 separately
662662 if (bBindAny && bindAddress == asio::ip::address_v6::any () && !v6_only_error)
663663 break ;
@@ -700,11 +700,20 @@ void StopRPCThreads()
700700 // First, cancel all timers and acceptors
701701 // This is not done automatically by ->stop(), and in some cases the destructor of
702702 // asio::io_service can hang if this is skipped.
703+ boost::system::error_code ec;
703704 BOOST_FOREACH (const boost::shared_ptr<ip::tcp::acceptor> &acceptor, rpc_acceptors)
704- acceptor->cancel ();
705+ {
706+ acceptor->cancel (ec);
707+ if (ec)
708+ LogPrintf (" %s: Warning: %s when cancelling acceptor" , __func__, ec.message ());
709+ }
705710 rpc_acceptors.clear ();
706711 BOOST_FOREACH (const PAIRTYPE (std::string, boost::shared_ptr<deadline_timer>) &timer, deadlineTimers)
707- timer.second ->cancel ();
712+ {
713+ timer.second ->cancel (ec);
714+ if (ec)
715+ LogPrintf (" %s: Warning: %s when cancelling timer" , __func__, ec.message ());
716+ }
708717 deadlineTimers.clear ();
709718
710719 rpc_io_service->stop ();
0 commit comments