From 8d55b650ddeecf9e76e4dd6e03951340cc6f39d7 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Mon, 5 Mar 2012 17:40:00 +0000 Subject: [PATCH] - Fix for #2177: don't wait forever to reconnect to the service during shutdown. In fact, don't wait at all. --- src/statistics/statistics_api.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index 100121f2f..c0b978f70 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c @@ -416,6 +416,18 @@ static void reconnect_later (struct GNUNET_STATISTICS_Handle *h) { GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->backoff_task); + if (h->do_destroy) + { + /* So we are shutting down and the service is not reachable. + * Chances are that it's down for good and we are not going to connect to + * it anymore. + * Give up and don't sync the rest of the data. + */ + GNUNET_break (0); + h->do_destroy = GNUNET_NO; + GNUNET_STATISTICS_destroy (h, GNUNET_NO); + return; + } h->backoff_task = GNUNET_SCHEDULER_add_delayed (h->backoff, &reconnect_task, h); h->backoff = GNUNET_TIME_relative_multiply (h->backoff, 2); @@ -837,6 +849,7 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first) if (h == NULL) return; + GNUNET_assert (GNUNET_NO == h->do_destroy); // Don't call twice. if (GNUNET_SCHEDULER_NO_TASK != h->backoff_task) { GNUNET_SCHEDULER_cancel (h->backoff_task); -- 2.25.1