From: Bart Polot Date: Thu, 10 Oct 2013 16:12:29 +0000 (+0000) Subject: - add polling API to connection X-Git-Tag: initial-import-from-subversion-38251~6612 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=eb003715aa2ef218876bb67cb3e204d9302a6db7;p=oweals%2Fgnunet.git - add polling API to connection --- 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) 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 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); 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 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, 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