From e4c99e0d5d4646e075cf343d7b890fe933045535 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 25 Jan 2012 20:26:21 +0000 Subject: [PATCH] -use proper backoff to make VPN connect/start faster --- src/vpn/vpn_api.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vpn/vpn_api.c b/src/vpn/vpn_api.c index 494c6d857..81282960e 100644 --- a/src/vpn/vpn_api.c +++ b/src/vpn/vpn_api.c @@ -63,6 +63,11 @@ struct GNUNET_VPN_Handle */ GNUNET_SCHEDULER_TaskIdentifier rt; + /** + * How long do we wait until we try to reconnect? + */ + struct GNUNET_TIME_Relative backoff; + /** * ID of the last request that was submitted to the service. */ @@ -402,7 +407,10 @@ reconnect (struct GNUNET_VPN_Handle *vh) vh->request_id_gen = 0; for (rr = vh->rr_head; NULL != rr; rr = rr->next) rr->request_id = 0; - vh->rt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, + vh->backoff = GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, + GNUNET_TIME_relative_min (GNUNET_TIME_relative_multiply (vh->backoff, 2), + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30))); + vh->rt = GNUNET_SCHEDULER_add_delayed (vh->backoff, &connect_task, vh); } -- 2.25.1