mirror of
https://github.com/monero-project/monero.git
synced 2025-05-06 04:25:02 -04:00
p2p: fix frequent weak_ptr exception on connection
When a handshake fails, it can fail due to timeout or destroyed connection, in which case the connection will be, or already is, closed, and we don't want to do it twice. Additionally, when closing a connection directly from the top level code, ensure the connection is gone from the m_connects list so it won't be used again. AFAICT this is now clean in netstat, /proc/PID/fd and print_cn. This fixes a noisy (but harmless) exception.
This commit is contained in:
parent
6c7d928f19
commit
21fe6a289b
2 changed files with 12 additions and 5 deletions
|
@ -949,7 +949,12 @@ bool async_protocol_handler_config<t_connection_context>::close(boost::uuids::uu
|
|||
{
|
||||
CRITICAL_REGION_LOCAL(m_connects_lock);
|
||||
async_protocol_handler<t_connection_context>* aph = find_connection(connection_id);
|
||||
return 0 != aph ? aph->close() : false;
|
||||
if (!aph)
|
||||
return false;
|
||||
if (!aph->close())
|
||||
return false;
|
||||
m_connects.erase(connection_id);
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
template<class t_connection_context>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue