diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-09-18 17:50:19 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-09-18 17:50:19 +0000 |
commit | 7ec04a4cc9cb5c00a2f1f664435c2214636668c2 (patch) | |
tree | a9431c54918b8947cf2d8af651ba0e553b3c75d6 /src/util/resolver_api.c | |
parent | e8882d4fcd826f2f4c3b8deff18f151e5522174c (diff) | |
download | gnunet-7ec04a4cc9cb5c00a2f1f664435c2214636668c2.tar.gz gnunet-7ec04a4cc9cb5c00a2f1f664435c2214636668c2.zip |
-avoid forever increasing backoffs on reconnect in normal operation
Diffstat (limited to 'src/util/resolver_api.c')
-rw-r--r-- | src/util/resolver_api.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index b95ee7d69..b35398619 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c | |||
@@ -206,15 +206,14 @@ check_config () | |||
206 | return; | 206 | return; |
207 | } | 207 | } |
208 | i = 0; | 208 | i = 0; |
209 | while (loopback[i] != NULL) | 209 | while (NULL != loopback[i]) |
210 | if (0 == strcasecmp (loopback[i++], hostname)) | 210 | if (0 == strcasecmp (loopback[i++], hostname)) |
211 | { | 211 | { |
212 | GNUNET_free (hostname); | 212 | GNUNET_free (hostname); |
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | LOG (GNUNET_ERROR_TYPE_ERROR, | 215 | LOG (GNUNET_ERROR_TYPE_ERROR, |
216 | _ | 216 | _("Must specify `%s' or numeric IP address for `%s' of `%s' in configuration!\n"), |
217 | ("Must specify `%s' or numeric IP address for `%s' of `%s' in configuration!\n"), | ||
218 | "localhost", "HOSTNAME", "resolver"); | 217 | "localhost", "HOSTNAME", "resolver"); |
219 | GNUNET_free (hostname); | 218 | GNUNET_free (hostname); |
220 | GNUNET_assert (0); | 219 | GNUNET_assert (0); |
@@ -250,12 +249,12 @@ GNUNET_RESOLVER_disconnect () | |||
250 | GNUNET_CLIENT_disconnect (client); | 249 | GNUNET_CLIENT_disconnect (client); |
251 | client = NULL; | 250 | client = NULL; |
252 | } | 251 | } |
253 | if (r_task != GNUNET_SCHEDULER_NO_TASK) | 252 | if (GNUNET_SCHEDULER_NO_TASK != r_task) |
254 | { | 253 | { |
255 | GNUNET_SCHEDULER_cancel (r_task); | 254 | GNUNET_SCHEDULER_cancel (r_task); |
256 | r_task = GNUNET_SCHEDULER_NO_TASK; | 255 | r_task = GNUNET_SCHEDULER_NO_TASK; |
257 | } | 256 | } |
258 | if (s_task != GNUNET_SCHEDULER_NO_TASK) | 257 | if (GNUNET_SCHEDULER_NO_TASK != s_task) |
259 | { | 258 | { |
260 | GNUNET_SCHEDULER_cancel (s_task); | 259 | GNUNET_SCHEDULER_cancel (s_task); |
261 | s_task = GNUNET_SCHEDULER_NO_TASK; | 260 | s_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -333,8 +332,9 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) | |||
333 | struct GNUNET_RESOLVER_RequestHandle *rh = cls; | 332 | struct GNUNET_RESOLVER_RequestHandle *rh = cls; |
334 | uint16_t size; | 333 | uint16_t size; |
335 | 334 | ||
336 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving response from DNS service\n"); | 335 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
337 | if (msg == NULL) | 336 | "Receiving response from DNS service\n"); |
337 | if (NULL == msg) | ||
338 | { | 338 | { |
339 | char buf[INET6_ADDRSTRLEN]; | 339 | char buf[INET6_ADDRSTRLEN]; |
340 | 340 | ||
@@ -347,7 +347,7 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) | |||
347 | _("Timeout trying to resolve hostname `%s'.\n"), | 347 | _("Timeout trying to resolve hostname `%s'.\n"), |
348 | (const char *) &rh[1]); | 348 | (const char *) &rh[1]); |
349 | /* check if request was canceled */ | 349 | /* check if request was canceled */ |
350 | if (rh->was_transmitted != GNUNET_SYSERR) | 350 | if (GNUNET_SYSERR != rh->was_transmitted) |
351 | { | 351 | { |
352 | if (NULL != rh->name_callback) | 352 | if (NULL != rh->name_callback) |
353 | { | 353 | { |
@@ -582,10 +582,12 @@ loopback_resolution (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
582 | * Task executed on system shutdown. | 582 | * Task executed on system shutdown. |
583 | */ | 583 | */ |
584 | static void | 584 | static void |
585 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 585 | shutdown_task (void *cls, |
586 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
586 | { | 587 | { |
587 | s_task = GNUNET_SCHEDULER_NO_TASK; | 588 | s_task = GNUNET_SCHEDULER_NO_TASK; |
588 | GNUNET_RESOLVER_disconnect (); | 589 | GNUNET_RESOLVER_disconnect (); |
590 | backoff = GNUNET_TIME_UNIT_MILLISECONDS; | ||
589 | } | 591 | } |
590 | 592 | ||
591 | 593 | ||
@@ -633,6 +635,7 @@ process_requests () | |||
633 | { | 635 | { |
634 | GNUNET_CLIENT_disconnect (client); | 636 | GNUNET_CLIENT_disconnect (client); |
635 | client = NULL; | 637 | client = NULL; |
638 | GNUNET_break (0); | ||
636 | reconnect (); | 639 | reconnect (); |
637 | return; | 640 | return; |
638 | } | 641 | } |
@@ -654,11 +657,13 @@ reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
654 | return; /* no work pending */ | 657 | return; /* no work pending */ |
655 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 658 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
656 | return; | 659 | return; |
657 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to DNS service\n"); | 660 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
661 | "Trying to connect to DNS service\n"); | ||
658 | client = GNUNET_CLIENT_connect ("resolver", resolver_cfg); | 662 | client = GNUNET_CLIENT_connect ("resolver", resolver_cfg); |
659 | if (NULL == client) | 663 | if (NULL == client) |
660 | { | 664 | { |
661 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect, will try again later\n"); | 665 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
666 | "Failed to connect, will try again later\n"); | ||
662 | reconnect (); | 667 | reconnect (); |
663 | return; | 668 | return; |
664 | } | 669 | } |
@@ -914,7 +919,9 @@ GNUNET_RESOLVER_hostname_resolve (int af, | |||
914 | "gethostname"); | 919 | "gethostname"); |
915 | return NULL; | 920 | return NULL; |
916 | } | 921 | } |
917 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Resolving our hostname `%s'\n", hostname); | 922 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
923 | "Resolving our hostname `%s'\n", | ||
924 | hostname); | ||
918 | return GNUNET_RESOLVER_ip_get (hostname, af, timeout, callback, cls); | 925 | return GNUNET_RESOLVER_ip_get (hostname, af, timeout, callback, cls); |
919 | } | 926 | } |
920 | 927 | ||