diff options
Diffstat (limited to 'src/util/resolver_api.c')
-rw-r--r-- | src/util/resolver_api.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index 69c49d1e8..87b7bbd46 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c | |||
@@ -52,7 +52,7 @@ static const char *loopback[] = { | |||
52 | /** | 52 | /** |
53 | * Configuration. | 53 | * Configuration. |
54 | */ | 54 | */ |
55 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 55 | static const struct GNUNET_CONFIGURATION_Handle *resolver_cfg; |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Our connection to the resolver service, created on-demand, but then | 58 | * Our connection to the resolver service, created on-demand, but then |
@@ -172,7 +172,7 @@ struct GNUNET_RESOLVER_RequestHandle | |||
172 | * (or equivalent). | 172 | * (or equivalent). |
173 | */ | 173 | */ |
174 | static void | 174 | static void |
175 | check_config (const struct GNUNET_CONFIGURATION_Handle *cfg) | 175 | check_config () |
176 | { | 176 | { |
177 | char *hostname; | 177 | char *hostname; |
178 | unsigned int i; | 178 | unsigned int i; |
@@ -191,8 +191,8 @@ check_config (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
191 | v6.sin6_len = sizeof (v6); | 191 | v6.sin6_len = sizeof (v6); |
192 | #endif | 192 | #endif |
193 | if (GNUNET_OK != | 193 | if (GNUNET_OK != |
194 | GNUNET_CONFIGURATION_get_value_string (cfg, "resolver", "HOSTNAME", | 194 | GNUNET_CONFIGURATION_get_value_string (resolver_cfg, "resolver", |
195 | &hostname)) | 195 | "HOSTNAME", &hostname)) |
196 | { | 196 | { |
197 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 197 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
198 | _("Must specify `%s' for `%s' in configuration!\n"), "HOSTNAME", | 198 | _("Must specify `%s' for `%s' in configuration!\n"), "HOSTNAME", |
@@ -224,15 +224,15 @@ check_config (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
224 | /** | 224 | /** |
225 | * Create the connection to the resolver service. | 225 | * Create the connection to the resolver service. |
226 | * | 226 | * |
227 | * @param c configuration to use | 227 | * @param cfg configuration to use |
228 | */ | 228 | */ |
229 | void | 229 | void |
230 | GNUNET_RESOLVER_connect (const struct GNUNET_CONFIGURATION_Handle *c) | 230 | GNUNET_RESOLVER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) |
231 | { | 231 | { |
232 | GNUNET_assert (NULL != c); | 232 | GNUNET_assert (NULL != cfg); |
233 | check_config (c); | ||
234 | backoff = GNUNET_TIME_UNIT_MILLISECONDS; | 233 | backoff = GNUNET_TIME_UNIT_MILLISECONDS; |
235 | cfg = c; | 234 | resolver_cfg = cfg; |
235 | check_config (); | ||
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
@@ -324,8 +324,6 @@ reconnect (); | |||
324 | 324 | ||
325 | /** | 325 | /** |
326 | * Process pending requests to the resolver. | 326 | * Process pending requests to the resolver. |
327 | * | ||
328 | * @param h handle to the resolver | ||
329 | */ | 327 | */ |
330 | static void | 328 | static void |
331 | process_requests (); | 329 | process_requests (); |
@@ -654,7 +652,7 @@ reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
654 | #if DEBUG_RESOLVER | 652 | #if DEBUG_RESOLVER |
655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to DNS service\n"); | 653 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to DNS service\n"); |
656 | #endif | 654 | #endif |
657 | client = GNUNET_CLIENT_connect ("resolver", cfg); | 655 | client = GNUNET_CLIENT_connect ("resolver", resolver_cfg); |
658 | if (NULL == client) | 656 | if (NULL == client) |
659 | { | 657 | { |
660 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 658 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -703,7 +701,7 @@ reconnect () | |||
703 | "Will try to connect to DNS service in %llu ms\n", | 701 | "Will try to connect to DNS service in %llu ms\n", |
704 | (unsigned long long) backoff.rel_value); | 702 | (unsigned long long) backoff.rel_value); |
705 | #endif | 703 | #endif |
706 | GNUNET_assert (NULL != cfg); | 704 | GNUNET_assert (NULL != resolver_cfg); |
707 | r_task = GNUNET_SCHEDULER_add_delayed (backoff, &reconnect_task, NULL); | 705 | r_task = GNUNET_SCHEDULER_add_delayed (backoff, &reconnect_task, NULL); |
708 | backoff = GNUNET_TIME_relative_multiply (backoff, 2); | 706 | backoff = GNUNET_TIME_relative_multiply (backoff, 2); |
709 | } | 707 | } |
@@ -823,7 +821,7 @@ GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa, socklen_t salen, | |||
823 | { | 821 | { |
824 | struct GNUNET_RESOLVER_RequestHandle *rh; | 822 | struct GNUNET_RESOLVER_RequestHandle *rh; |
825 | 823 | ||
826 | check_config (cfg); | 824 | check_config (); |
827 | rh = GNUNET_malloc (sizeof (struct GNUNET_RESOLVER_RequestHandle) + salen); | 825 | rh = GNUNET_malloc (sizeof (struct GNUNET_RESOLVER_RequestHandle) + salen); |
828 | rh->name_callback = callback; | 826 | rh->name_callback = callback; |
829 | rh->cls = cls; | 827 | rh->cls = cls; |