Another attampt at fixing #4010: mark unavailable neighbors in FlowControl struct...
authorBart Polot <bart@net.in.tum.de>
Wed, 9 Dec 2015 18:56:41 +0000 (18:56 +0000)
committerBart Polot <bart@net.in.tum.de>
Wed, 9 Dec 2015 18:56:41 +0000 (18:56 +0000)
src/cadet/gnunet-service-cadet_connection.c

index c61f4a53ed82c8a990199f3fc1cc7ff28b804943..c40821c307b86073c84d2b3b10513679d19959c4 100644 (file)
@@ -71,6 +71,7 @@ struct CadetFlowControl
 
   /**
    * How many messages do we accept in the queue.
+   * If 0, the connection is broken in this direction (next hop disconnected).
    */
   unsigned int queue_max;
 
@@ -1412,6 +1413,11 @@ poll_sent (void *cls,
     LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL canceled on shutdown\n");
     return;
   }
+  if (0 == fc->queue_max)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL cancelled: neighbor disconnected\n");
+    return;
+  }
   LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL sent for %s, scheduling new one!\n",
        GCC_2s (c));
   GNUNET_assert (NULL == fc->poll_task);
@@ -3318,6 +3324,7 @@ GCC_allow (struct CadetConnection *c, unsigned int buffer, int fwd)
 void
 GCC_neighbor_disconnected (struct CadetConnection *c, struct CadetPeer *peer)
 {
+  struct CadetFlowControl *fc;
   struct CadetPeer *hop;
   char peer_name[16];
   int fwd;
@@ -3348,7 +3355,12 @@ GCC_neighbor_disconnected (struct CadetConnection *c, struct CadetPeer *peer)
     GCC_check_connections ();
     return;
   }
+  /* Mark FlowControl towards the peer as unavaliable. */
+  fc = fwd ? &c->bck_fc : &c->fwd_fc;
+  fc->queue_max = 0;
+
   send_broken (c, &my_full_id, GCP_get_id (peer), fwd);
+
   /* Connection will have at least one pending message
    * (the one we just scheduled), so delay destruction
    * and remove from map so we don't use accidentally. */
@@ -3735,6 +3747,13 @@ GCC_start_poll (struct CadetConnection *c, int fwd)
          fc->poll_task, fc->poll_msg);
     return;
   }
+  if (0 == fc->queue_max)
+  {
+    /* Should not be needed, traffic should've been cancelled. */
+    GNUNET_break (0);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "  POLL not possible, peer disconnected\n");
+    return;
+  }
   LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL started on request\n");
   fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
                                                 &connection_poll,