fix for mantis 2355
authorMatthias Wachs <wachs@net.in.tum.de>
Tue, 15 May 2012 08:09:16 +0000 (08:09 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Tue, 15 May 2012 08:09:16 +0000 (08:09 +0000)
src/transport/gnunet-service-transport_neighbours.c

index 821d66b54cc9fe9fee28357b7b39425c883e7a65..2ee73fec790853b6743d4e9e47869c7d610bfb82 100644 (file)
@@ -795,9 +795,6 @@ free_neighbour (struct NeighbourMapEntry *n)
   struct MessageQueue *mq;
   struct GNUNET_TRANSPORT_PluginFunctions *papi;
 
-  GNUNET_assert (GNUNET_YES ==
-                 GNUNET_CONTAINER_multihashmap_remove (neighbours,
-                                                       &n->id.hashPubKey, n));
   n->is_active = NULL; /* always free'd by its own continuation! */
 
   /* fail messages currently in the queue */
@@ -818,7 +815,6 @@ free_neighbour (struct NeighbourMapEntry *n)
                           GNUNET_NO);
     disconnect_notify_cb (callback_cls, &n->id);
   }
-  n->state = S_DISCONNECT_FINISHED;
 
   /* FIXME-PLUGIN-API: This does not seem to guarantee that all
      transport sessions eventually get killed due to inactivity; they
@@ -833,6 +829,12 @@ free_neighbour (struct NeighbourMapEntry *n)
        (NULL != (papi = GST_plugins_find (n->primary_address.address->transport_name))) )
     papi->disconnect (papi->cls, &n->id);
 
+  n->state = S_DISCONNECT_FINISHED;
+
+  GNUNET_assert (GNUNET_YES ==
+                 GNUNET_CONTAINER_multihashmap_remove (neighbours,
+                                                       &n->id.hashPubKey, n));
+
   /* cut transport-level connection */
   free_address (&n->primary_address);
   free_address (&n->alternative_address);
@@ -1054,6 +1056,12 @@ transmit_send_continuation (void *cls,
   struct NeighbourMapEntry *n;
 
   n = lookup_neighbour (receiver);
+  if (NULL == n)
+  {
+    GNUNET_break (0);
+    return;
+  }
+
   if (n->is_active == mq)
   {
     /* this is still "our" neighbour, remove us from its queue