aboutsummaryrefslogtreecommitdiff
path: root/src/service/transport/transport_api2_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/transport/transport_api2_core.c')
-rw-r--r--src/service/transport/transport_api2_core.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/service/transport/transport_api2_core.c b/src/service/transport/transport_api2_core.c
index 3eb6c651e..598eef184 100644
--- a/src/service/transport/transport_api2_core.c
+++ b/src/service/transport/transport_api2_core.c
@@ -160,6 +160,11 @@ struct GNUNET_TRANSPORT_CoreHandle
160 struct GNUNET_TIME_Relative reconnect_delay; 160 struct GNUNET_TIME_Relative reconnect_delay;
161 161
162 /** 162 /**
163 * Transport connection started at.
164 */
165 struct GNUNET_TIME_Absolute restarted_at;
166
167 /**
163 * Should we check that @e self matches what the service thinks? 168 * Should we check that @e self matches what the service thinks?
164 * (if #GNUNET_NO, then @e self is all zeros!). 169 * (if #GNUNET_NO, then @e self is all zeros!).
165 */ 170 */
@@ -628,6 +633,7 @@ reconnect (void *cls)
628 GNUNET_assert (NULL == h->mq); 633 GNUNET_assert (NULL == h->mq);
629 h->mq = 634 h->mq =
630 GNUNET_CLIENT_connect (h->cfg, "transport", handlers, &mq_error_handler, h); 635 GNUNET_CLIENT_connect (h->cfg, "transport", handlers, &mq_error_handler, h);
636 h->restarted_at = GNUNET_TIME_absolute_get ();
631 if (NULL == h->mq) 637 if (NULL == h->mq)
632 return; 638 return;
633 env = GNUNET_MQ_msg (s, GNUNET_MESSAGE_TYPE_TRANSPORT_START); 639 env = GNUNET_MQ_msg (s, GNUNET_MESSAGE_TYPE_TRANSPORT_START);
@@ -670,6 +676,20 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_CoreHandle *h)
670{ 676{
671 GNUNET_assert (NULL == h->reconnect_task); 677 GNUNET_assert (NULL == h->reconnect_task);
672 disconnect (h); 678 disconnect (h);
679 {
680 /* Reduce delay based on runtime of the connection,
681 so that there is a cool-down if a connection is up
682 for a while. */
683 struct GNUNET_TIME_Relative runtime;
684 unsigned int minutes;
685
686 runtime = GNUNET_TIME_absolute_get_duration (h->restarted_at);
687 minutes = runtime.rel_value_us / GNUNET_TIME_UNIT_MINUTES.rel_value_us;
688 if (minutes > 31)
689 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
690 else
691 h->reconnect_delay.rel_value_us >>= minutes;
692 }
673 LOG (GNUNET_ERROR_TYPE_DEBUG, 693 LOG (GNUNET_ERROR_TYPE_DEBUG,
674 "Scheduling task to reconnect to transport service in %s.\n", 694 "Scheduling task to reconnect to transport service in %s.\n",
675 GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, GNUNET_YES)); 695 GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, GNUNET_YES));