- document code, small sanity checks
authorBart Polot <bart@net.in.tum.de>
Sat, 5 Jul 2014 00:13:06 +0000 (00:13 +0000)
committerBart Polot <bart@net.in.tum.de>
Sat, 5 Jul 2014 00:13:06 +0000 (00:13 +0000)
src/cadet/gnunet-service-cadet_connection.c

index a706aeed3e09a959d0b345859f8db93d306eeba1..6b9b07aa6497812940a142ea8e6a77eb36052427 100644 (file)
@@ -1803,6 +1803,7 @@ GCC_handle_broken (void* cls,
     return GNUNET_OK;
   }
 
+  t = c->t;
   fwd = is_fwd (c, id);
   if (GCC_is_terminal (c, fwd))
   {
@@ -1811,13 +1812,21 @@ GCC_handle_broken (void* cls,
     struct CadetPeer *endpoint;
     int pending_msgs;
 
+    if (NULL == t)
+    {
+      /* A terminal connection should not have 't' set to NULL. */
+      GNUNET_break (0);
+      return GNUNET_OK;
+    }
     neighbor = get_hop (c, !fwd);
     endpoint = GCP_get_short (c->path->peers[c->path->length - 1]);
     path_invalidate (c->path);
     GCP_notify_broken_link (endpoint, &msg->peer1, &msg->peer2);
     c->state = CADET_CONNECTION_DESTROYED;
-    t = c->t;
     pending_msgs = c->pending_messages;
+
+    /* GCP_connection_pop will destroy the connection when the last message
+     * is popped! Do not use 'c' after the call. */
     while (NULL != (out_msg = GCP_connection_pop (neighbor, c)))
     {
       GNUNET_assert (NULL ==