diff --git a/src/cpp/ripple/Peer.cpp b/src/cpp/ripple/Peer.cpp index e3dcda0985..be23d13759 100644 --- a/src/cpp/ripple/Peer.cpp +++ b/src/cpp/ripple/Peer.cpp @@ -278,9 +278,21 @@ void Peer::handleConnect(const boost::system::error_code& error, boost::asio::ip // - We don't bother remembering the inbound IP or port. Only useful for debugging. void Peer::connected(const boost::system::error_code& error) { - boost::asio::ip::tcp::endpoint ep = getSocket().remote_endpoint(); - int iPort = ep.port(); - std::string strIp = ep.address().to_string(); + boost::asio::ip::tcp::endpoint ep; + int iPort; + std::string strIp; + + try + { + ep = getSocket().remote_endpoint(); + iPort = ep.port(); + strIp = ep.address().to_string(); + } + catch (...) + { + detach("edc", false); + return; + } mClientConnect = false; mIpPortConnect = make_pair(strIp, iPort); diff --git a/src/cpp/ripple/RPCDoor.cpp b/src/cpp/ripple/RPCDoor.cpp index da79c9b486..214afe3c22 100644 --- a/src/cpp/ripple/RPCDoor.cpp +++ b/src/cpp/ripple/RPCDoor.cpp @@ -50,8 +50,16 @@ void RPCDoor::handleConnect(RPCServer::pointer new_connection, if (!error) { // Restrict callers by IP - if (!isClientAllowed(new_connection->getSocket().remote_endpoint().address().to_string())) + try { + if (!isClientAllowed(new_connection->getSocket().remote_endpoint().address().to_string())) + { + startListening(); + return; + } + } + catch (...) + { // client may have disconnected startListening(); return; } diff --git a/src/cpp/ripple/WSHandler.h b/src/cpp/ripple/WSHandler.h index 0b62ec3f20..4903d44a55 100644 --- a/src/cpp/ripple/WSHandler.h +++ b/src/cpp/ripple/WSHandler.h @@ -142,7 +142,13 @@ public: { boost::mutex::scoped_lock sl(mMapLock); - mMap[cpClient] = boost::make_shared< WSConnection >(this, cpClient); + try + { + mMap[cpClient] = boost::make_shared< WSConnection >(this, cpClient); + } + catch (...) + { + } } void on_pong(connection_ptr cpClient, std::string data)