rpc: Add acceptors only when listening succeeded

Rebased-From: 6afa493
Rebased-By: Wladimir J. van der Laan <laanwj@gmail.com>
This commit is contained in:
Wladimir J. van der Laan 2014-06-19 09:39:51 +02:00
parent a3788527a2
commit b64b1c6e9f
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6

View File

@ -566,7 +566,6 @@ void StartRPCThreads()
try try
{ {
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);
acceptor->open(endpoint.protocol()); acceptor->open(endpoint.protocol());
acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
@ -578,6 +577,7 @@ void StartRPCThreads()
RPCListen(acceptor, *rpc_ssl_context, fUseSSL); RPCListen(acceptor, *rpc_ssl_context, fUseSSL);
rpc_acceptors.push_back(acceptor);
fListening = true; fListening = true;
} }
catch(boost::system::system_error &e) catch(boost::system::system_error &e)
@ -592,7 +592,6 @@ void StartRPCThreads()
endpoint.address(bindAddress); endpoint.address(bindAddress);
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);
acceptor->open(endpoint.protocol()); acceptor->open(endpoint.protocol());
acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
acceptor->bind(endpoint); acceptor->bind(endpoint);
@ -600,6 +599,7 @@ void StartRPCThreads()
RPCListen(acceptor, *rpc_ssl_context, fUseSSL); RPCListen(acceptor, *rpc_ssl_context, fUseSSL);
rpc_acceptors.push_back(acceptor);
fListening = true; fListening = true;
} }
} }