epee: close connection when the peer has done so

This fixes rapid reconnections failing as the peer hasn't yet
worked out the other side is gone, and will reject "duplicate"
connections until a timeout.
This commit is contained in:
moneromooo-monero 2019-11-11 20:05:00 +00:00
parent a48ef0a65a
commit 3d649d528a
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3

View file

@ -410,7 +410,12 @@ PRAGMA_WARNING_DISABLE_VS(4355)
else else
{ {
_dbg3("[sock " << socket().native_handle() << "] peer closed connection"); _dbg3("[sock " << socket().native_handle() << "] peer closed connection");
if (m_ready_to_close) bool do_shutdown = false;
CRITICAL_REGION_BEGIN(m_send_que_lock);
if(!m_send_que.size())
do_shutdown = true;
CRITICAL_REGION_END();
if (m_ready_to_close || do_shutdown)
shutdown(); shutdown();
} }
m_ready_to_close = true; m_ready_to_close = true;
@ -470,6 +475,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
{ {
MERROR("SSL handshake failed"); MERROR("SSL handshake failed");
boost::interprocess::ipcdetail::atomic_write32(&m_want_close_connection, 1); boost::interprocess::ipcdetail::atomic_write32(&m_want_close_connection, 1);
m_ready_to_close = true;
bool do_shutdown = false; bool do_shutdown = false;
CRITICAL_REGION_BEGIN(m_send_que_lock); CRITICAL_REGION_BEGIN(m_send_que_lock);
if(!m_send_que.size()) if(!m_send_que.size())