Only touch remote_endpoint under a try/catch block.

This commit is contained in:
JoelKatz
2013-06-07 05:11:20 -07:00
parent 6b4b239e72
commit b305e682ed
3 changed files with 31 additions and 5 deletions

View File

@@ -412,9 +412,21 @@ void PeerImp::handleConnect(const boost::system::error_code& error, boost::asio:
// - We don't bother remembering the inbound IP or port. Only useful for debugging.
void PeerImp::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);