gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r32541 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r32541 - gnunet/src/mesh
Date: Thu, 6 Mar 2014 02:36:18 +0100

Author: bartpolot
Date: 2014-03-06 02:36:18 +0100 (Thu, 06 Mar 2014)
New Revision: 32541

Modified:
   gnunet/src/mesh/gnunet-service-mesh_connection.c
Log:
- refactor fwd/bck connection keepalive

Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2014-03-06 01:36:16 UTC 
(rev 32540)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2014-03-06 01:36:18 UTC 
(rev 32541)
@@ -855,7 +855,7 @@
  * @param fwd Is this a FWD keepalive? (owner -> dest).
  */
 static void
-connection_keepalive (struct MeshConnection *c, int fwd)
+send_connection_keepalive (struct MeshConnection *c, int fwd)
 {
   struct GNUNET_MESH_ConnectionKeepAlive *msg;
   size_t size = sizeof (struct GNUNET_MESH_ConnectionKeepAlive);
@@ -920,7 +920,7 @@
       connection_recreate (c, fwd);
       break;
     case MESH_CONNECTION_READY:
-      connection_keepalive (c, fwd);
+      send_connection_keepalive (c, fwd);
       break;
     default:
       break;
@@ -928,34 +928,54 @@
 }
 
 
+
 /**
- * Keep the connection alive in the FWD direction.
+ * Keep the connection alive.
  *
- * @param cls Closure (connection to keepalive).
- * @param tc TaskContext.
+ * @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_fwd_keepalive (void *cls,
-                          const struct GNUNET_SCHEDULER_TaskContext *tc)
+connection_keepalive (struct MeshConnection *c, int fwd, int shutdown)
 {
-  struct MeshConnection *c = cls;
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "%s keepalive for %s\n",
+       GM_f2s (fwd), GMC_2s (c));
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "FWD keepalive for %s\n", GMC_2s (c));
-  c->fwd_maintenance_task = GNUNET_SCHEDULER_NO_TASK;
-  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+  if (fwd)
+    c->fwd_maintenance_task = GNUNET_SCHEDULER_NO_TASK;
+  else
+    c->bck_maintenance_task = GNUNET_SCHEDULER_NO_TASK;
+
+  if (GNUNET_NO != shutdown)
     return;
 
-  connection_maintain (c, GNUNET_YES);
+  connection_maintain (c, fwd);
 
   /* Next execution will be scheduled by message_sent */
 }
 
 
 /**
+ * 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_keepalive ((struct MeshConnection *) cls,
+                        GNUNET_YES,
+                        tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN);
+}
+
+
+/**
  * Keep the connection alive in the BCK direction.
  *
- * TODO refactor and merge with connection_fwd_keepalive.
- *
  * @param cls Closure (connection to keepalive).
  * @param tc TaskContext.
  */
@@ -963,15 +983,9 @@
 connection_bck_keepalive (void *cls,
                           const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  struct MeshConnection *c = cls;
-
-  c->bck_maintenance_task = GNUNET_SCHEDULER_NO_TASK;
-  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
-    return;
-
-  connection_maintain (c, GNUNET_NO);
-
-  /* Next execution will be scheduled by message_sent */
+  connection_keepalive ((struct MeshConnection *) cls,
+                        GNUNET_NO,
+                        tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN);
 }
 
 




reply via email to

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