gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35047 - gnunet/src/rps


From: gnunet
Subject: [GNUnet-SVN] r35047 - gnunet/src/rps
Date: Thu, 29 Jan 2015 00:11:28 +0100

Author: ch3
Date: 2015-01-29 00:11:28 +0100 (Thu, 29 Jan 2015)
New Revision: 35047

Modified:
   gnunet/src/rps/gnunet-service-rps.c
Log:
- fixed double free problem

Modified: gnunet/src/rps/gnunet-service-rps.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps.c 2015-01-28 23:11:24 UTC (rev 35046)
+++ gnunet/src/rps/gnunet-service-rps.c 2015-01-28 23:11:28 UTC (rev 35047)
@@ -1422,9 +1422,9 @@
 
   if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_remove_all (peer_map, key))
     LOG (GNUNET_ERROR_TYPE_WARNING, "removing peer from peer_map failed\n");
+  else
+    GNUNET_free (peer_ctx);
 
-  /* FIXME this will be called twice until the fixme in line 1451 is fixed */
-  GNUNET_free (peer_ctx);
   return GNUNET_YES;
 }
 
@@ -1448,7 +1448,6 @@
   }
 
 
-  /* FIXME instead of this, destroy every known channel */
   {
   if (GNUNET_SYSERR == GNUNET_CONTAINER_multipeermap_iterate (peer_map, 
peer_remove_cb, NULL))
     LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -1538,22 +1537,26 @@
   struct GNUNET_PeerIdentity *peer;
   struct PeerContext *peer_ctx;
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel to remote peer was destroyed.\n");
-
   peer = (struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info (
       (struct GNUNET_CADET_Channel *) channel, GNUNET_CADET_OPTION_PEER);
        // Guess simply casting isn't the nicest way...
        // FIXME wait for cadet to change this function
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up channel to peer %s\n",
+       GNUNET_i2s (peer));
+
   RPS_sampler_reinitialise_by_value (peer);
 
-  peer_ctx = GNUNET_CONTAINER_multipeermap_get (peer_map, peer);
+  if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer))
+  {
+    peer_ctx = GNUNET_CONTAINER_multipeermap_get (peer_map, peer);
 
-  if (NULL == peer_ctx) /* It could have been removed by shutdown_task */
-    return;
+    if (NULL == peer_ctx) /* It could have been removed by shutdown_task */
+      return;
 
-  /* Somwewhat {ab,re}use the iterator function */
-  /* Cast to void is ok, because it's used as void in peer_remove_cb */
-  (void) peer_remove_cb ((void *) channel, peer, peer_ctx);
+    /* Somwewhat {ab,re}use the iterator function */
+    /* Cast to void is ok, because it's used as void in peer_remove_cb */
+    (void) peer_remove_cb ((void *) channel, peer, peer_ctx);
+  }
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]