Fix for #4553
[oweals/gnunet.git] / src / cadet / gnunet-service-cadet_connection.c
index 0827f53ec9c187a481b94e35a63afa57c0875cc1..188041feb235a536aa65c0f6e826b45c33bff3a5 100644 (file)
@@ -1192,11 +1192,10 @@ connection_maintain (struct CadetConnection *c, int fwd)
  *
  * @param c Connection to keep alive.
  * @param fwd Direction.
- * @param shutdown Are we shutting down? (Don't send traffic)
- *                 Non-zero value for true, not necessarily GNUNET_YES.
  */
 static void
-connection_keepalive (struct CadetConnection *c, int fwd, int shutdown)
+connection_keepalive (struct CadetConnection *c,
+                     int fwd)
 {
   GCC_check_connections ();
   LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1207,10 +1206,6 @@ connection_keepalive (struct CadetConnection *c, int fwd, int shutdown)
     c->fwd_maintenance_task = NULL;
   else
     c->bck_maintenance_task = NULL;
-
-  if (GNUNET_NO != shutdown)
-    return;
-
   connection_maintain (c, fwd);
   GCC_check_connections ();
   /* Next execution will be scheduled by message_sent or _maintain*/
@@ -1221,16 +1216,15 @@ connection_keepalive (struct CadetConnection *c, int fwd, int shutdown)
  * Keep the connection alive in the FWD direction.
  *
  * @param cls Closure (connection to keepalive).
- * @param tc TaskContext.
  */
 static void
-connection_fwd_keepalive (void *cls,
-                          const struct GNUNET_SCHEDULER_TaskContext *tc)
+connection_fwd_keepalive (void *cls)
 {
+  struct CadetConnection *c = cls;
+
   GCC_check_connections ();
-  connection_keepalive ((struct CadetConnection *) cls,
-                        GNUNET_YES,
-                        tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN);
+  connection_keepalive (c,
+                        GNUNET_YES);
   GCC_check_connections ();
 }
 
@@ -1239,16 +1233,15 @@ connection_fwd_keepalive (void *cls,
  * Keep the connection alive in the BCK direction.
  *
  * @param cls Closure (connection to keepalive).
- * @param tc TaskContext.
  */
 static void
-connection_bck_keepalive (void *cls,
-                          const struct GNUNET_SCHEDULER_TaskContext *tc)
+connection_bck_keepalive (void *cls)
 {
+  struct CadetConnection *c = cls;
+
   GCC_check_connections ();
-  connection_keepalive ((struct CadetConnection *) cls,
-                        GNUNET_NO,
-                        tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN);
+  connection_keepalive (c,
+                        GNUNET_NO);
   GCC_check_connections ();
 }
 
@@ -1400,11 +1393,9 @@ connection_cancel_queues (struct CadetConnection *c,
  * possibly due to a missed ACK. Poll the neighbor about its ACK status.
  *
  * @param cls Closure (poll ctx).
- * @param tc TaskContext.
  */
 static void
-connection_poll (void *cls,
-                 const struct GNUNET_SCHEDULER_TaskContext *tc);
+connection_poll (void *cls);
 
 
 /**
@@ -1453,10 +1444,9 @@ poll_sent (void *cls,
  * possibly due to a missed ACK. Poll the neighbor about its ACK status.
  *
  * @param cls Closure (poll ctx).
- * @param tc TaskContext.
  */
 static void
-connection_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+connection_poll (void *cls)
 {
   struct CadetFlowControl *fc = cls;
   struct GNUNET_CADET_Poll msg;
@@ -1465,11 +1455,6 @@ connection_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   fc->poll_task = NULL;
   GCC_check_connections ();
-  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
-  {
-    return;
-  }
-
   c = fc->c;
   fwd = fc == &c->fwd_fc;
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Polling connection %s %s\n",
@@ -1564,7 +1549,7 @@ connection_timeout (struct CadetConnection *c, int fwd)
   }
 
   /* If dest, salvage queued traffic. */
-  if (GCC_is_origin (c, !fwd))
+  if (GCC_is_terminal (c, fwd))
   {
     const struct GNUNET_PeerIdentity *next_hop;
 
@@ -1586,17 +1571,13 @@ connection_timeout (struct CadetConnection *c, int fwd)
  * Destroys connection if called.
  *
  * @param cls Closure (connection to destroy).
- * @param tc TaskContext.
  */
 static void
-connection_fwd_timeout (void *cls,
-                        const struct GNUNET_SCHEDULER_TaskContext *tc)
+connection_fwd_timeout (void *cls)
 {
   struct CadetConnection *c = cls;
 
   c->fwd_maintenance_task = NULL;
-  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
-    return;
   GCC_check_connections ();
   connection_timeout (c, GNUNET_YES);
   GCC_check_connections ();
@@ -1608,17 +1589,13 @@ connection_fwd_timeout (void *cls,
  * Destroys connection if called.
  *
  * @param cls Closure (connection to destroy).
- * @param tc TaskContext
  */
 static void
-connection_bck_timeout (void *cls,
-                        const struct GNUNET_SCHEDULER_TaskContext *tc)
+connection_bck_timeout (void *cls)
 {
   struct CadetConnection *c = cls;
 
   c->bck_maintenance_task = NULL;
-  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
-    return;
   GCC_check_connections ();
   connection_timeout (c, GNUNET_NO);
   GCC_check_connections ();
@@ -1761,17 +1738,13 @@ does_connection_exist (struct CadetConnection *conn)
  * connection with the same path, and destroy one if so.
  *
  * @param cls Closure (connection to check).
- * @param tc Task context.
  */
 static void
-check_duplicates (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+check_duplicates (void *cls)
 {
   struct CadetConnection *c = cls;
 
   c->check_duplicates_task = NULL;
-  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
-    return;
-
   if (GNUNET_YES == does_connection_exist (c))
   {
     GCT_debug (c->t, GNUNET_ERROR_TYPE_DEBUG);
@@ -1781,7 +1754,6 @@ check_duplicates (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 }
 
 
-
 /**
  * Wait for enough time to let any dead connections time out and check for
  * any remaining duplicates.
@@ -1795,7 +1767,6 @@ schedule_check_duplicates (struct CadetConnection *c)
 
   if (NULL != c->check_duplicates_task)
     return;
-
   delay = GNUNET_TIME_relative_multiply (refresh_connection_time, 5);
   c->check_duplicates_task = GNUNET_SCHEDULER_add_delayed (delay,
                                                            &check_duplicates,
@@ -1803,7 +1774,6 @@ schedule_check_duplicates (struct CadetConnection *c)
 }
 
 
-
 /**
  * Add the connection to the list of both neighbors.
  *
@@ -1901,7 +1871,8 @@ unregister_neighbors (struct CadetConnection *c)
  * @param disconnected Peer that disconnected.
  */
 static void
-invalidate_paths (struct CadetConnection *c, struct CadetPeer *disconnected)
+invalidate_paths (struct CadetConnection *c,
+                 struct CadetPeer *disconnected)
 {
   struct CadetPeer *peer;
   unsigned int i;