aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-12-30 17:24:42 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-03-31 20:29:41 +0000
commit21fe6a289b934bd96bf83d5d23ece14ec850df27 (patch)
tree79d5407aa6b29fce958fdebe05bd10f5c7047ab6 /contrib/epee
parentMerge pull request #6336 (diff)
downloadmonero-21fe6a289b934bd96bf83d5d23ece14ec850df27.tar.xz
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.
Diffstat (limited to 'contrib/epee')
-rw-r--r--contrib/epee/include/net/levin_protocol_handler_async.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h
index 5774c0ba7..1341a4ae6 100644
--- a/contrib/epee/include/net/levin_protocol_handler_async.h
+++ b/contrib/epee/include/net/levin_protocol_handler_async.h
@@ -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>