From 6795812d9db9bc981e62042447bdffbf2ee4a8d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Julius=20B=C3=BCnger?= Date: Thu, 21 Feb 2019 16:36:05 +0100 Subject: [PATCH] RPS service: Check existence of peer before destruction This is only a workaround. What was causing an issue was that, during the removal of a peer (from all datastructures), the peer was also removed from the peer_map, causing the final destruction call to fail. With this workaround the peer is only destroyed if it is still in the peer_map. --- src/rps/gnunet-service-rps.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index a448d17e4..35ed1022f 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c @@ -2676,11 +2676,23 @@ static void remove_peer (struct Sub *sub, const struct GNUNET_PeerIdentity *peer) { - (void) View_remove_peer (sub->view, peer); - CustomPeerMap_remove_peer (sub->pull_map, peer); - CustomPeerMap_remove_peer (sub->push_map, peer); - RPS_sampler_reinitialise_by_value (sub->sampler, peer); - destroy_peer (get_peer_ctx (sub->peer_map, peer)); + (void) View_remove_peer (sub->view, + peer); + CustomPeerMap_remove_peer (sub->pull_map, + peer); + CustomPeerMap_remove_peer (sub->push_map, + peer); + RPS_sampler_reinitialise_by_value (sub->sampler, + peer); + /* We want to destroy the peer now. + * Sometimes, it just seems that it's already been removed from the peer_map, + * so check the peer_map first. */ + if (GNUNET_YES == check_peer_known (sub->peer_map, + peer)) + { + destroy_peer (get_peer_ctx (sub->peer_map, + peer)); + } } -- 2.25.1