aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-10-10 16:12:29 +0000
committerBart Polot <bart@net.in.tum.de>2013-10-10 16:12:29 +0000
commiteb003715aa2ef218876bb67cb3e204d9302a6db7 (patch)
treeee3feb27b5469b3548a09d6b6dc8411498021493 /src/mesh
parent0f50b74b830b74d16ba4ceded679dbe8cf206c5c (diff)
downloadgnunet-eb003715aa2ef218876bb67cb3e204d9302a6db7.tar.gz
gnunet-eb003715aa2ef218876bb67cb3e204d9302a6db7.zip
- add polling API to connection
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh_connection.c48
-rw-r--r--src/mesh/gnunet-service-mesh_connection.h25
-rw-r--r--src/mesh/gnunet-service-mesh_peer.c4
3 files changed, 74 insertions, 3 deletions
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c
index ee19d6706..7e2f61569 100644
--- a/src/mesh/gnunet-service-mesh_connection.c
+++ b/src/mesh/gnunet-service-mesh_connection.c
@@ -2065,4 +2065,52 @@ GMC_send_destroy (struct MeshConnection *c)
2065 if (GNUNET_NO == GMC_is_terminal (c, GNUNET_NO)) 2065 if (GNUNET_NO == GMC_is_terminal (c, GNUNET_NO))
2066 GMC_send_prebuilt_message (&msg.header, c, NULL, GNUNET_NO); 2066 GMC_send_prebuilt_message (&msg.header, c, NULL, GNUNET_NO);
2067 c->destroy = GNUNET_YES; 2067 c->destroy = GNUNET_YES;
2068}
2069
2070
2071/**
2072 * @brief Start a polling timer for the connection.
2073 *
2074 * When a neighbor does not accept more traffic on the connection it could be
2075 * caused by a simple congestion or by a lost ACK. Polling enables to check
2076 * for the lastest ACK status for a connection.
2077 *
2078 * @param c Connection.
2079 * @param fwd Should we poll in the FWD direction?
2080 */
2081void
2082GMC_start_poll (struct MeshConnection *c, int fwd)
2083{
2084 struct MeshFlowControl *fc;
2085
2086 fc = fwd ? &c->fwd_fc : &c->bck_fc;
2087 if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task)
2088 {
2089 return;
2090 }
2091 fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
2092 &connection_poll,
2093 fc);
2094}
2095
2096
2097/**
2098 * @brief Stop polling a connection for ACKs.
2099 *
2100 * Once we have enough ACKs for future traffic, polls are no longer necessary.
2101 *
2102 * @param c Connection.
2103 * @param fwd Should we stop the poll in the FWD direction?
2104 */
2105void
2106GMC_stop_poll (struct MeshConnection *c, int fwd)
2107{
2108 struct MeshFlowControl *fc;
2109
2110 fc = fwd ? &c->fwd_fc : &c->bck_fc;
2111 if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task)
2112 {
2113 GNUNET_SCHEDULER_cancel (fc->poll_task);
2114 fc->poll_task = GNUNET_SCHEDULER_NO_TASK;
2115 }
2068} \ No newline at end of file 2116} \ No newline at end of file
diff --git a/src/mesh/gnunet-service-mesh_connection.h b/src/mesh/gnunet-service-mesh_connection.h
index 436ae01c7..131bd9dc2 100644
--- a/src/mesh/gnunet-service-mesh_connection.h
+++ b/src/mesh/gnunet-service-mesh_connection.h
@@ -417,6 +417,31 @@ GMC_send_create (struct MeshConnection *connection);
417void 417void
418GMC_send_destroy (struct MeshConnection *c); 418GMC_send_destroy (struct MeshConnection *c);
419 419
420/**
421 * @brief Start a polling timer for the connection.
422 *
423 * When a neighbor does not accept more traffic on the connection it could be
424 * caused by a simple congestion or by a lost ACK. Polling enables to check
425 * for the lastest ACK status for a connection.
426 *
427 * @param c Connection.
428 * @param fwd Should we poll in the FWD direction?
429 */
430void
431GMC_start_poll (struct MeshConnection *c, int fwd);
432
433
434/**
435 * @brief Stop polling a connection for ACKs.
436 *
437 * Once we have enough ACKs for future traffic, polls are no longer necessary.
438 *
439 * @param c Connection.
440 * @param fwd Should we stop the poll in the FWD direction?
441 */
442void
443GMC_stop_poll (struct MeshConnection *c, int fwd);
444
420#if 0 /* keep Emacsens' auto-indent happy */ 445#if 0 /* keep Emacsens' auto-indent happy */
421{ 446{
422#endif 447#endif
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c
index 72eabab28..940377b33 100644
--- a/src/mesh/gnunet-service-mesh_peer.c
+++ b/src/mesh/gnunet-service-mesh_peer.c
@@ -1159,9 +1159,7 @@ GMP_queue_add (void *cls, uint16_t type, size_t size,
1159 LOG (GNUNET_ERROR_TYPE_DEBUG, 1159 LOG (GNUNET_ERROR_TYPE_DEBUG,
1160 "no buffer space (%u > %u): starting poll\n", 1160 "no buffer space (%u > %u): starting poll\n",
1161 fc->last_pid_sent + 1, fc->last_ack_recv); 1161 fc->last_pid_sent + 1, fc->last_ack_recv);
1162 fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time, 1162 GMC_start_poll (c, fwd);
1163 &connection_poll,
1164 fc);
1165 } 1163 }
1166 } 1164 }
1167 else 1165 else