From 5808f72f509844068eff4a80127b15675913531d Mon Sep 17 00:00:00 2001 From: Yat Ho Date: Tue, 3 Oct 2023 00:57:48 +0800 Subject: [PATCH] fix: assertion failed: port_empty in `tr_swarm::remove_peer()` (#6062) --- libtransmission/peer-mgr.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libtransmission/peer-mgr.cc b/libtransmission/peer-mgr.cc index de2b27cc6..75ac84b12 100644 --- a/libtransmission/peer-mgr.cc +++ b/libtransmission/peer-mgr.cc @@ -273,8 +273,7 @@ public: auto* const peer_info = peer->peer_info; auto const socket_address = peer->socket_address(); - auto const listen_socket_address = peer_info->listen_socket_address(); - auto const was_incoming = peer->is_incoming_connection(); + [[maybe_unused]] auto const is_incoming = peer->is_incoming_connection(); TR_ASSERT(peer_info != nullptr); --stats.peer_count; @@ -288,15 +287,16 @@ public: delete peer; - if (was_incoming) + if (std::empty(peer_info->listen_port())) // is not connectable { - [[maybe_unused]] auto const port_empty = std::empty(peer_info->listen_port()); - if (incoming_pool.erase(socket_address) != 0U) - { - TR_ASSERT(port_empty); - } + TR_ASSERT(is_incoming); + [[maybe_unused]] auto const count = incoming_pool.erase(socket_address); + TR_ASSERT(count != 0U); + } + else + { + graveyard_pool.erase(peer_info->listen_socket_address()); } - graveyard_pool.erase(listen_socket_address); } void remove_all_peers()