catches socket exception when other end closes the connection right as we are about to

This commit is contained in:
Peter Thorson
2011-10-26 16:47:20 -05:00
parent f3769e041a
commit af2fa69822

View File

@@ -711,9 +711,18 @@ bool session::validate_app_close_status(uint16_t status) {
void session::drop_tcp(bool dropped_by_me) {
m_timer.cancel();
if (m_socket.is_open()) {
m_socket.shutdown(tcp::socket::shutdown_both);
m_socket.close();
try {
if (m_socket.is_open()) {
m_socket.shutdown(tcp::socket::shutdown_both);
m_socket.close();
}
} catch (boost::system::system_error& e) {
if (e.code() == boost::asio::error::not_connected) {
// this means the socket was disconnected by the other side before
// we had a chance to. Ignore and continue.
} else {
throw e;
}
}
m_dropped_by_me = dropped_by_me;
m_state = STATE_CLOSED;