RPS service: Check existence of peer before destruction
authorJulius Bünger <buenger@mytum.de>
Thu, 21 Feb 2019 15:36:05 +0000 (16:36 +0100)
committerJulius Bünger <buenger@mytum.de>
Thu, 21 Feb 2019 15:36:05 +0000 (16:36 +0100)
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

index a448d17e45855578945c2d2cf5489045dbf56da3..35ed1022f90b94dd96643ed99a1de049b362be88 100644 (file)
@@ -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));
+  }
 }