aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-11-15 15:24:16 +0000
committerBart Polot <bart@net.in.tum.de>2012-11-15 15:24:16 +0000
commitec6e8eb2d1ed3f2ca8e1af8767a8c1fa71641c4d (patch)
treec7c6d0ddaca9f9331bb4cff75df03f10f46639de
parentf76b38decdf5b4414124fdb82575437a1aaaee82 (diff)
downloadgnunet-ec6e8eb2d1ed3f2ca8e1af8767a8c1fa71641c4d.tar.gz
gnunet-ec6e8eb2d1ed3f2ca8e1af8767a8c1fa71641c4d.zip
- exponential backoff for ACK polling
-rw-r--r--src/mesh/gnunet-service-mesh.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 5bc13880e..969b83a18 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -61,7 +61,9 @@
61#define MESH_DEBUG_CONNECTION GNUNET_NO 61#define MESH_DEBUG_CONNECTION GNUNET_NO
62#define MESH_DEBUG_TIMING __LINUX__ && GNUNET_NO 62#define MESH_DEBUG_TIMING __LINUX__ && GNUNET_NO
63 63
64#define MESH_POLL_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) 64#define MESH_MAX_POLL_TIME GNUNET_TIME_relative_multiply (\
65 GNUNET_TIME_UNIT_MINUTES,\
66 10)
65 67
66#if MESH_DEBUG_CONNECTION 68#if MESH_DEBUG_CONNECTION
67#define DEBUG_CONN(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) 69#define DEBUG_CONN(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
@@ -584,7 +586,12 @@ struct MeshTunnelChildInfo
584 /** 586 /**
585 * Task to poll peer in case of a stall. 587 * Task to poll peer in case of a stall.
586 */ 588 */
587 GNUNET_SCHEDULER_TaskIdentifier fc_poll; 589 GNUNET_SCHEDULER_TaskIdentifier fc_poll;
590
591 /**
592 * Time to use for next polling call.
593 */
594 struct GNUNET_TIME_Relative fc_poll_time;
588}; 595};
589 596
590 597
@@ -2994,7 +3001,7 @@ peer_info_add_path_to_origin (struct MeshPeerInfo *peer_info,
2994 * Function called if the connection to the peer has been stalled for a while, 3001 * Function called if the connection to the peer has been stalled for a while,
2995 * possibly due to a missed ACK. Poll the peer about its ACK status. 3002 * possibly due to a missed ACK. Poll the peer about its ACK status.
2996 * 3003 *
2997 * @param cls Closure (info about regex search). 3004 * @param cls Closure (cinfo).
2998 * @param tc TaskContext. 3005 * @param tc TaskContext.
2999 */ 3006 */
3000static void 3007static void
@@ -3020,8 +3027,11 @@ tunnel_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3020 3027
3021 GNUNET_PEER_resolve (cinfo->id, &id); 3028 GNUNET_PEER_resolve (cinfo->id, &id);
3022 send_prebuilt_message (&msg.header, &id, cinfo->t); 3029 send_prebuilt_message (&msg.header, &id, cinfo->t);
3023 cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, 3030 cinfo->fc_poll_time = GNUNET_TIME_relative_min (
3024 &tunnel_poll, cinfo); 3031 MESH_MAX_POLL_TIME,
3032 GNUNET_TIME_relative_multiply (cinfo->fc_poll_time, 2));
3033 cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed (cinfo->fc_poll_time,
3034 &tunnel_poll, cinfo);
3025} 3035}
3026 3036
3027 3037
@@ -3692,6 +3702,9 @@ tunnel_get_neighbor_fc (struct MeshTunnel *t,
3692 cinfo->bck_ack = delta; 3702 cinfo->bck_ack = delta;
3693 cinfo->bck_pid = -1; 3703 cinfo->bck_pid = -1;
3694 3704
3705 cinfo->fc_poll = GNUNET_SCHEDULER_NO_TASK;
3706 cinfo->fc_poll_time = GNUNET_TIME_UNIT_SECONDS;
3707
3695 cinfo->send_buffer = 3708 cinfo->send_buffer =
3696 GNUNET_malloc (sizeof(struct MeshPeerQueue *) * t->fwd_queue_max); 3709 GNUNET_malloc (sizeof(struct MeshPeerQueue *) * t->fwd_queue_max);
3697 3710
@@ -5197,8 +5210,10 @@ queue_send (void *cls, size_t size, void *buf)
5197 if (NULL == cinfo) 5210 if (NULL == cinfo)
5198 cinfo = tunnel_get_neighbor_fc (t, &dst_id); 5211 cinfo = tunnel_get_neighbor_fc (t, &dst_id);
5199 if (GNUNET_SCHEDULER_NO_TASK == cinfo->fc_poll) 5212 if (GNUNET_SCHEDULER_NO_TASK == cinfo->fc_poll)
5200 cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed(MESH_POLL_TIME, 5213 {
5201 &tunnel_poll, cinfo); 5214 cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed (cinfo->fc_poll_time,
5215 &tunnel_poll, cinfo);
5216 }
5202 } 5217 }
5203 } 5218 }
5204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* return %d\n", data_size); 5219 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* return %d\n", data_size);
@@ -6037,6 +6052,12 @@ handle_mesh_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
6037 cinfo->fwd_ack = ack; 6052 cinfo->fwd_ack = ack;
6038 tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_ACK); 6053 tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_ACK);
6039 tunnel_unlock_fwd_queues (t); 6054 tunnel_unlock_fwd_queues (t);
6055 if (GNUNET_SCHEDULER_NO_TASK != cinfo->fc_poll)
6056 {
6057 GNUNET_SCHEDULER_cancel (cinfo->fc_poll);
6058 cinfo->fc_poll = GNUNET_SCHEDULER_NO_TASK;
6059 cinfo->fc_poll_time = GNUNET_TIME_UNIT_SECONDS;
6060 }
6040 } 6061 }
6041 else 6062 else
6042 { 6063 {