mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Merge pull request #4358
6afa493
rpc: Add acceptors only when listening succeeded (Wladimir J. van der Laan)33e5b42
rpc: Ignore and log errors during cancel (Wladimir J. van der Laan)
This commit is contained in:
commit
7eb49c79f0
@ -642,7 +642,6 @@ void StartRPCThreads()
|
|||||||
LogPrintf("Binding RPC on address %s port %i (IPv4+IPv6 bind any: %i)\n", bindAddress.to_string(), endpoint.port(), bBindAny);
|
LogPrintf("Binding RPC on address %s port %i (IPv4+IPv6 bind any: %i)\n", bindAddress.to_string(), endpoint.port(), bBindAny);
|
||||||
boost::system::error_code v6_only_error;
|
boost::system::error_code v6_only_error;
|
||||||
boost::shared_ptr<ip::tcp::acceptor> acceptor(new ip::tcp::acceptor(*rpc_io_service));
|
boost::shared_ptr<ip::tcp::acceptor> acceptor(new ip::tcp::acceptor(*rpc_io_service));
|
||||||
rpc_acceptors.push_back(acceptor);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
acceptor->open(endpoint.protocol());
|
acceptor->open(endpoint.protocol());
|
||||||
@ -658,6 +657,7 @@ void StartRPCThreads()
|
|||||||
RPCListen(acceptor, *rpc_ssl_context, fUseSSL);
|
RPCListen(acceptor, *rpc_ssl_context, fUseSSL);
|
||||||
|
|
||||||
fListening = true;
|
fListening = true;
|
||||||
|
rpc_acceptors.push_back(acceptor);
|
||||||
// If dual IPv6/IPv4 bind succesful, skip binding to IPv4 separately
|
// If dual IPv6/IPv4 bind succesful, skip binding to IPv4 separately
|
||||||
if(bBindAny && bindAddress == asio::ip::address_v6::any() && !v6_only_error)
|
if(bBindAny && bindAddress == asio::ip::address_v6::any() && !v6_only_error)
|
||||||
break;
|
break;
|
||||||
@ -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