- add polling API to connection
authorBart Polot <bart@net.in.tum.de>
Thu, 10 Oct 2013 16:12:29 +0000 (16:12 +0000)
committerBart Polot <bart@net.in.tum.de>
Thu, 10 Oct 2013 16:12:29 +0000 (16:12 +0000)
src/mesh/gnunet-service-mesh_connection.c
src/mesh/gnunet-service-mesh_connection.h
src/mesh/gnunet-service-mesh_peer.c

index ee19d6706f3fd97be39c1e956e029522df07d78c..7e2f61569bd7e970a6e34dd9f1b7a72a8b87cceb 100644 (file)
@@ -2065,4 +2065,52 @@ GMC_send_destroy (struct MeshConnection *c)
   if (GNUNET_NO == GMC_is_terminal (c, GNUNET_NO))
     GMC_send_prebuilt_message (&msg.header, c, NULL, GNUNET_NO);
   c->destroy = GNUNET_YES;
+}
+
+
+/**
+ * @brief Start a polling timer for the connection.
+ *
+ * When a neighbor does not accept more traffic on the connection it could be
+ * caused by a simple congestion or by a lost ACK. Polling enables to check
+ * for the lastest ACK status for a connection.
+ *
+ * @param c Connection.
+ * @param fwd Should we poll in the FWD direction?
+ */
+void
+GMC_start_poll (struct MeshConnection *c, int fwd)
+{
+  struct MeshFlowControl *fc;
+
+  fc = fwd ? &c->fwd_fc : &c->bck_fc;
+  if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task)
+  {
+    return;
+  }
+  fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
+                                                &connection_poll,
+                                                fc);
+}
+
+
+/**
+ * @brief Stop polling a connection for ACKs.
+ *
+ * Once we have enough ACKs for future traffic, polls are no longer necessary.
+ *
+ * @param c Connection.
+ * @param fwd Should we stop the poll in the FWD direction?
+ */
+void
+GMC_stop_poll (struct MeshConnection *c, int fwd)
+{
+  struct MeshFlowControl *fc;
+
+  fc = fwd ? &c->fwd_fc : &c->bck_fc;
+  if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task)
+  {
+    GNUNET_SCHEDULER_cancel (fc->poll_task);
+    fc->poll_task = GNUNET_SCHEDULER_NO_TASK;
+  }
 }
\ No newline at end of file
index 436ae01c72d0c27d3559d34eb01e5f56bbf7624b..131bd9dc276d5d9a848e62bc7ea7decd90804d0e 100644 (file)
@@ -417,6 +417,31 @@ GMC_send_create (struct MeshConnection *connection);
 void
 GMC_send_destroy (struct MeshConnection *c);
 
+/**
+ * @brief Start a polling timer for the connection.
+ *
+ * When a neighbor does not accept more traffic on the connection it could be
+ * caused by a simple congestion or by a lost ACK. Polling enables to check
+ * for the lastest ACK status for a connection.
+ *
+ * @param c Connection.
+ * @param fwd Should we poll in the FWD direction?
+ */
+void
+GMC_start_poll (struct MeshConnection *c, int fwd);
+
+
+/**
+ * @brief Stop polling a connection for ACKs.
+ *
+ * Once we have enough ACKs for future traffic, polls are no longer necessary.
+ *
+ * @param c Connection.
+ * @param fwd Should we stop the poll in the FWD direction?
+ */
+void
+GMC_stop_poll (struct MeshConnection *c, int fwd);
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif
index 72eabab285e988253001bd6f9e2998d6519921e9..940377b3318cd60e22cd512358ed8bbc053990b5 100644 (file)
@@ -1159,9 +1159,7 @@ GMP_queue_add (void *cls, uint16_t type, size_t size,
       LOG (GNUNET_ERROR_TYPE_DEBUG,
                   "no buffer space (%u > %u): starting poll\n",
                   fc->last_pid_sent + 1, fc->last_ack_recv);
-      fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
-                                                    &connection_poll,
-                                                    fc);
+      GMC_start_poll (c, fwd);
     }
   }
   else