gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r38246 - gnunet/src/cadet


From: gnunet
Subject: [GNUnet-SVN] r38246 - gnunet/src/cadet
Date: Fri, 4 Nov 2016 10:47:25 +0100

Author: bartpolot
Date: 2016-11-04 10:47:25 +0100 (Fri, 04 Nov 2016)
New Revision: 38246

Modified:
   gnunet/src/cadet/gnunet-service-cadet_connection.c
Log:
- refactor connection upkeep code, remove unneeded functions

Modified: gnunet/src/cadet/gnunet-service-cadet_connection.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_connection.c  2016-11-04 09:47:24 UTC 
(rev 38245)
+++ gnunet/src/cadet/gnunet-service-cadet_connection.c  2016-11-04 09:47:25 UTC 
(rev 38246)
@@ -517,27 +517,15 @@
 
 
 /**
- * Callback called when a queued ACK message is sent.
+ * Function called if a connection has been stalled for a while,
+ * possibly due to a missed ACK. Poll the neighbor about its ACK status.
  *
- * @param cls Closure (FC).
- * @param c Connection this message was on.
- * @param q Queue handler this call invalidates.
- * @param type Type of message sent.
- * @param fwd Was this a FWD going message?
- * @param size Size of the message.
+ * @param cls Closure (poll ctx).
  */
 static void
-ack_sent (void *cls,
-          struct CadetConnection *c,
-          struct CadetConnectionQueue *q,
-          uint16_t type, int fwd, size_t size)
-{
-  struct CadetFlowControl *fc = cls;
+send_poll (void *cls);
 
-  fc->ack_msg = NULL;
-}
 
-
 /**
  * Send an ACK on the connection, informing the predecessor about
  * the available buffer space. Should not be called in case the peer
@@ -621,7 +609,7 @@
 
   prev_fc->ack_msg = GCC_send_prebuilt_message (&msg.header, UINT16_MAX, ack,
                                                 c, !fwd, GNUNET_YES,
-                                                &ack_sent, prev_fc);
+                                                NULL, NULL);
   GNUNET_assert (NULL != prev_fc->ack_msg);
   GCC_check_connections ();
 }
@@ -797,6 +785,23 @@
 
     case GNUNET_MESSAGE_TYPE_CADET_POLL:
       fc->poll_msg = NULL;
+      if (2 == c->destroy)
+      {
+        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);
+      fc->poll_time = GNUNET_TIME_STD_BACKOFF (fc->poll_time);
+      fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
+                                                    &send_poll, fc);
+      LOG (GNUNET_ERROR_TYPE_DEBUG, " task %u\n", fc->poll_task);
       break;
 
     case GNUNET_MESSAGE_TYPE_CADET_ACK:
@@ -1406,60 +1411,9 @@
  * @param cls Closure (poll ctx).
  */
 static void
-send_connection_poll (void *cls);
-
-
-/**
- * Callback called when a queued POLL message is sent.
- *
- * @param cls Closure (flow control context).
- * @param c Connection this message was on.
- * @param q Queue handler this call invalidates.
- * @param type Type of message sent.
- * @param fwd Was this a FWD going message?
- * @param size Size of the message.
- */
-static void
-poll_sent (void *cls,
-           struct CadetConnection *c,
-           struct CadetConnectionQueue *q,
-           uint16_t type, int fwd, size_t size)
+send_poll (void *cls)
 {
   struct CadetFlowControl *fc = cls;
-
-  GNUNET_assert (fc->poll_msg == q);
-  fc->poll_msg = NULL;
-  if (2 == c->destroy)
-  {
-    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);
-  fc->poll_time = GNUNET_TIME_STD_BACKOFF (fc->poll_time);
-  fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
-                                                &send_connection_poll,
-                                                fc);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, " task %u\n", fc->poll_task);
-}
-
-
-/**
- * Function called if a connection has been stalled for a while,
- * possibly due to a missed ACK. Poll the neighbor about its ACK status.
- *
- * @param cls Closure (poll ctx).
- */
-static void
-send_connection_poll (void *cls)
-{
-  struct CadetFlowControl *fc = cls;
   struct GNUNET_CADET_Poll msg;
   struct CadetConnection *c;
   int fwd;
@@ -1478,7 +1432,7 @@
   LOG (GNUNET_ERROR_TYPE_DEBUG, " last pid sent: %u\n", fc->last_pid_sent);
   fc->poll_msg =
       GCC_send_prebuilt_message (&msg.header, UINT16_MAX, fc->last_pid_sent, c,
-                                 fc == &c->fwd_fc, GNUNET_YES, &poll_sent, fc);
+                                 fc == &c->fwd_fc, GNUNET_YES, NULL, NULL);
   GNUNET_assert (NULL != fc->poll_msg);
   GCC_check_connections ();
 }
@@ -3540,9 +3494,7 @@
     return;
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL started on request\n");
-  fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
-                                                &send_connection_poll,
-                                                fc);
+  fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time, &send_poll, fc);
 }
 
 




reply via email to

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