diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-26 11:51:03 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-26 11:51:03 +0000 |
commit | 4b3aa82c084d5ef81614f18d9e9c7d7ceddf1c4a (patch) | |
tree | cd37a84211dcc20205c713ccdb8037dbfa675561 /src/hostlist | |
parent | 97a1b44e62c2f04629c55ba699810bc9bb3268a6 (diff) | |
download | gnunet-4b3aa82c084d5ef81614f18d9e9c7d7ceddf1c4a.tar.gz gnunet-4b3aa82c084d5ef81614f18d9e9c7d7ceddf1c4a.zip |
Diffstat (limited to 'src/hostlist')
-rw-r--r-- | src/hostlist/hostlist-client.c | 210 |
1 files changed, 109 insertions, 101 deletions
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 084277af4..6e61586ae 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c | |||
@@ -149,47 +149,36 @@ static CURL *curl; | |||
149 | static CURLM *multi; | 149 | static CURLM *multi; |
150 | 150 | ||
151 | /** | 151 | /** |
152 | * ID of the current task scheduled. | 152 | * Amount of time we wait between hostlist downloads. |
153 | */ | ||
154 | static struct GNUNET_TIME_Relative hostlist_delay; | ||
155 | |||
156 | /** | ||
157 | * ID of the task, checking if hostlist download should take plate | ||
153 | */ | 158 | */ |
154 | static GNUNET_SCHEDULER_TaskIdentifier ti_check_download; | 159 | static GNUNET_SCHEDULER_TaskIdentifier ti_check_download; |
155 | 160 | ||
156 | /** | 161 | /** |
157 | * ID of the current task scheduled. | 162 | * ID of the task downloading the hostlist |
158 | */ | 163 | */ |
159 | static GNUNET_SCHEDULER_TaskIdentifier ti_download; | 164 | static GNUNET_SCHEDULER_TaskIdentifier ti_download; |
160 | 165 | ||
161 | /** | 166 | /** |
162 | * ID of the current hostlist saving task scheduled. | 167 | * ID of the task saving the hostlsit in a regular intervall |
163 | */ | 168 | */ |
164 | static GNUNET_SCHEDULER_TaskIdentifier ti_saving_task; | 169 | static GNUNET_SCHEDULER_TaskIdentifier ti_saving_task; |
165 | 170 | ||
166 | /** | 171 | /** |
167 | * ID of the current hostlist saving task scheduled. | 172 | * ID of the task called to initiate a download |
168 | */ | 173 | */ |
169 | static GNUNET_SCHEDULER_TaskIdentifier ti_download_dispatcher_task; | 174 | static GNUNET_SCHEDULER_TaskIdentifier ti_download_dispatcher_task; |
170 | 175 | ||
171 | |||
172 | /** | 176 | /** |
173 | * ID of the task checking the intervall between to hostlist tests | 177 | * ID of the task controlling the locking between two hostlist tests |
174 | */ | 178 | */ |
175 | static GNUNET_SCHEDULER_TaskIdentifier ti_testing_intervall_task; | 179 | static GNUNET_SCHEDULER_TaskIdentifier ti_testing_intervall_task; |
176 | 180 | ||
177 | /** | 181 | /** |
178 | * Amount of time we wait between hostlist downloads. | ||
179 | */ | ||
180 | static struct GNUNET_TIME_Relative hostlist_delay; | ||
181 | |||
182 | /** | ||
183 | * Set to GNUNET_YES if the current URL had some problems. | ||
184 | */ | ||
185 | static int bogus_url; | ||
186 | |||
187 | /** | ||
188 | * Number of active connections (according to core service). | ||
189 | */ | ||
190 | static unsigned int connection_count; | ||
191 | |||
192 | /** | ||
193 | * At what time MUST the current hostlist request be done? | 182 | * At what time MUST the current hostlist request be done? |
194 | */ | 183 | */ |
195 | static struct GNUNET_TIME_Absolute end_time; | 184 | static struct GNUNET_TIME_Absolute end_time; |
@@ -219,31 +208,50 @@ static unsigned int linked_list_size; | |||
219 | */ | 208 | */ |
220 | static struct Hostlist * hostlist_to_test; | 209 | static struct Hostlist * hostlist_to_test; |
221 | 210 | ||
222 | static int testing_hostlist; | 211 | /** |
212 | * Set to GNUNET_YES if the current URL had some problems. | ||
213 | */ | ||
214 | static int stat_bogus_url; | ||
223 | 215 | ||
224 | static int testing_allowed; | 216 | /** |
217 | * Value controlling if a hostlist is tested at the moment | ||
218 | */ | ||
219 | static int stat_testing_hostlist; | ||
225 | 220 | ||
226 | static int download_in_progress; | 221 | /** |
222 | * Value controlling if a hostlist testing is allowed at the moment | ||
223 | */ | ||
224 | static int stat_testing_allowed; | ||
227 | 225 | ||
228 | /** | 226 | /** |
229 | * Value saying if preconfigured is used | 227 | * Value controlling if a hostlist download is running at the moment |
230 | */ | 228 | */ |
231 | static unsigned int use_preconfigured_list; | 229 | static int stat_download_in_progress; |
232 | 230 | ||
233 | /** | 231 | /** |
232 | * Value saying if a preconfigured bootstrap server is used | ||
233 | */ | ||
234 | static unsigned int stat_use_bootstrap; | ||
235 | /** | ||
234 | * Set if we are allowed to learn new hostlists and use them | 236 | * Set if we are allowed to learn new hostlists and use them |
235 | */ | 237 | */ |
236 | static int learning; | 238 | static int stat_learning; |
239 | |||
240 | /** | ||
241 | * Value saying if hostlist download was successful | ||
242 | */ | ||
243 | static unsigned int stat_download_successful; | ||
237 | 244 | ||
238 | /** | 245 | /** |
239 | * Value saying how many valid HELLO messages were obtained during download | 246 | * Value saying how many valid HELLO messages were obtained during download |
240 | */ | 247 | */ |
241 | static unsigned int hellos_obtained; | 248 | static unsigned int stat_hellos_obtained; |
242 | 249 | ||
243 | /** | 250 | /** |
244 | * Value saying if hostlist download was successful | 251 | * Number of active connections (according to core service). |
245 | */ | 252 | */ |
246 | static unsigned int download_successful; | 253 | static unsigned int stat_connection_count; |
254 | |||
247 | 255 | ||
248 | /** | 256 | /** |
249 | * Process downloaded bits by calling callback on each HELLO. | 257 | * Process downloaded bits by calling callback on each HELLO. |
@@ -255,7 +263,7 @@ static unsigned int download_successful; | |||
255 | * @return number of bytes that were processed (always size*nmemb) | 263 | * @return number of bytes that were processed (always size*nmemb) |
256 | */ | 264 | */ |
257 | static size_t | 265 | static size_t |
258 | download_hostlist_processor (void *ptr, | 266 | callback_download (void *ptr, |
259 | size_t size, | 267 | size_t size, |
260 | size_t nmemb, | 268 | size_t nmemb, |
261 | void *ctx) | 269 | void *ctx) |
@@ -268,7 +276,7 @@ download_hostlist_processor (void *ptr, | |||
268 | uint16_t msize; | 276 | uint16_t msize; |
269 | 277 | ||
270 | total = size * nmemb; | 278 | total = size * nmemb; |
271 | if ( (total == 0) || (bogus_url) ) | 279 | if ( (total == 0) || (stat_bogus_url) ) |
272 | { | 280 | { |
273 | return total; /* ok, no data or bogus data */ | 281 | return total; /* ok, no data or bogus data */ |
274 | } | 282 | } |
@@ -304,7 +312,7 @@ download_hostlist_processor (void *ptr, | |||
304 | _("Invalid `%s' message received from hostlist at `%s'\n"), | 312 | _("Invalid `%s' message received from hostlist at `%s'\n"), |
305 | "HELLO", | 313 | "HELLO", |
306 | current_url); | 314 | current_url); |
307 | bogus_url = 1; | 315 | stat_bogus_url = 1; |
308 | return total; | 316 | return total; |
309 | } | 317 | } |
310 | if (download_pos < msize) | 318 | if (download_pos < msize) |
@@ -323,7 +331,7 @@ download_hostlist_processor (void *ptr, | |||
323 | gettext_noop ("# valid HELLOs downloaded from hostlist servers"), | 331 | gettext_noop ("# valid HELLOs downloaded from hostlist servers"), |
324 | 1, | 332 | 1, |
325 | GNUNET_NO); | 333 | GNUNET_NO); |
326 | hellos_obtained++; | 334 | stat_hellos_obtained++; |
327 | GNUNET_TRANSPORT_offer_hello (transport, msg); | 335 | GNUNET_TRANSPORT_offer_hello (transport, msg); |
328 | } | 336 | } |
329 | else | 337 | else |
@@ -336,7 +344,7 @@ download_hostlist_processor (void *ptr, | |||
336 | _("Invalid `%s' message received from hostlist at `%s'\n"), | 344 | _("Invalid `%s' message received from hostlist at `%s'\n"), |
337 | "HELLO", | 345 | "HELLO", |
338 | current_url); | 346 | current_url); |
339 | bogus_url = GNUNET_YES; | 347 | stat_bogus_url = GNUNET_YES; |
340 | return total; | 348 | return total; |
341 | } | 349 | } |
342 | memmove (download_buffer, | 350 | memmove (download_buffer, |
@@ -354,7 +362,7 @@ download_hostlist_processor (void *ptr, | |||
354 | * @return NULL if there is no URL available | 362 | * @return NULL if there is no URL available |
355 | */ | 363 | */ |
356 | static char * | 364 | static char * |
357 | get_bootstrap_url () | 365 | get_bootstrap_server () |
358 | { | 366 | { |
359 | char *servers; | 367 | char *servers; |
360 | char *ret; | 368 | char *ret; |
@@ -420,21 +428,21 @@ get_bootstrap_url () | |||
420 | * @return uri to use, NULL if there is no URL available | 428 | * @return uri to use, NULL if there is no URL available |
421 | */ | 429 | */ |
422 | static char * | 430 | static char * |
423 | get_list_url () | 431 | download_get_url () |
424 | { | 432 | { |
425 | uint32_t index; | 433 | uint32_t index; |
426 | unsigned int counter; | 434 | unsigned int counter; |
427 | struct Hostlist * pos; | 435 | struct Hostlist * pos; |
428 | 436 | ||
429 | if ( GNUNET_NO == learning) | 437 | if ( GNUNET_NO == stat_learning) |
430 | { | 438 | { |
431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
432 | "Using preconfigured bootstrap server\n"); | 440 | "Using preconfigured bootstrap server\n"); |
433 | current_hostlist = NULL; | 441 | current_hostlist = NULL; |
434 | return get_bootstrap_url(); | 442 | return get_bootstrap_server(); |
435 | } | 443 | } |
436 | 444 | ||
437 | if ( ( GNUNET_YES == testing_hostlist) && (NULL != hostlist_to_test) ) | 445 | if ( ( GNUNET_YES == stat_testing_hostlist) && (NULL != hostlist_to_test) ) |
438 | { | 446 | { |
439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 447 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
440 | "Testing new advertised hostlist if it is obtainable\n"); | 448 | "Testing new advertised hostlist if it is obtainable\n"); |
@@ -442,13 +450,13 @@ get_list_url () | |||
442 | return strdup(hostlist_to_test->hostlist_uri); | 450 | return strdup(hostlist_to_test->hostlist_uri); |
443 | } | 451 | } |
444 | 452 | ||
445 | if ( (GNUNET_YES == use_preconfigured_list) || | 453 | if ( (GNUNET_YES == stat_use_bootstrap) || |
446 | (linked_list_size == 0) ) | 454 | (linked_list_size == 0) ) |
447 | { | 455 | { |
448 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 456 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
449 | "Using preconfigured bootstrap server\n"); | 457 | "Using preconfigured bootstrap server\n"); |
450 | current_hostlist = NULL; | 458 | current_hostlist = NULL; |
451 | return get_bootstrap_url(); | 459 | return get_bootstrap_server(); |
452 | } | 460 | } |
453 | index = GNUNET_CRYPTO_random_u32 ( GNUNET_CRYPTO_QUALITY_WEAK, linked_list_size); | 461 | index = GNUNET_CRYPTO_random_u32 ( GNUNET_CRYPTO_QUALITY_WEAK, linked_list_size); |
454 | counter = 0; | 462 | counter = 0; |
@@ -468,7 +476,7 @@ get_list_url () | |||
468 | #define CURL_EASY_SETOPT(c, a, b) do { ret = curl_easy_setopt(c, a, b); if (ret != CURLE_OK) GNUNET_log(GNUNET_ERROR_TYPE_WARNING, _("%s failed at %s:%d: `%s'\n"), "curl_easy_setopt", __FILE__, __LINE__, curl_easy_strerror(ret)); } while (0); | 476 | #define CURL_EASY_SETOPT(c, a, b) do { ret = curl_easy_setopt(c, a, b); if (ret != CURLE_OK) GNUNET_log(GNUNET_ERROR_TYPE_WARNING, _("%s failed at %s:%d: `%s'\n"), "curl_easy_setopt", __FILE__, __LINE__, curl_easy_strerror(ret)); } while (0); |
469 | 477 | ||
470 | /** | 478 | /** |
471 | * Method to load persistent hostlist file during hostlist client shutdown | 479 | * Method to save hostlist to a file during hostlist client shutdown |
472 | * @param shutdown set if called because of shutdown, entries in linked list will be destroyed | 480 | * @param shutdown set if called because of shutdown, entries in linked list will be destroyed |
473 | */ | 481 | */ |
474 | static void save_hostlist_file ( int shutdown ); | 482 | static void save_hostlist_file ( int shutdown ); |
@@ -509,7 +517,7 @@ static uint64_t checked_sub (uint64_t val1, uint64_t val2) | |||
509 | } | 517 | } |
510 | 518 | ||
511 | /** | 519 | /** |
512 | * Method to check if URI is in hostlist linked list | 520 | * Method to check if a URI is in hostlist linked list |
513 | * @param uri uri to check | 521 | * @param uri uri to check |
514 | * @return GNUNET_YES if existing in linked list, GNUNET_NO if not | 522 | * @return GNUNET_YES if existing in linked list, GNUNET_NO if not |
515 | */ | 523 | */ |
@@ -530,7 +538,7 @@ linked_list_contains (const char * uri) | |||
530 | 538 | ||
531 | 539 | ||
532 | /** | 540 | /** |
533 | * Method returning the uri with the lowest quality in the datastore | 541 | * Method returning the hostlist element with the lowest quality in the datastore |
534 | * @return hostlist with lowest quality | 542 | * @return hostlist with lowest quality |
535 | */ | 543 | */ |
536 | static struct Hostlist * | 544 | static struct Hostlist * |
@@ -588,7 +596,7 @@ insert_hostlist ( void ) | |||
588 | 596 | ||
589 | GNUNET_free (lowest_quality); | 597 | GNUNET_free (lowest_quality); |
590 | 598 | ||
591 | testing_hostlist = GNUNET_NO; | 599 | stat_testing_hostlist = GNUNET_NO; |
592 | return; | 600 | return; |
593 | } | 601 | } |
594 | 602 | ||
@@ -599,15 +607,15 @@ insert_hostlist ( void ) | |||
599 | static void update_hostlist ( ) | 607 | static void update_hostlist ( ) |
600 | { | 608 | { |
601 | char *stat; | 609 | char *stat; |
602 | if ( ((use_preconfigured_list == GNUNET_NO) && ( NULL != current_hostlist )) || | 610 | if ( ((stat_use_bootstrap == GNUNET_NO) && ( NULL != current_hostlist )) || |
603 | ((testing_hostlist == GNUNET_YES) && ( NULL != current_hostlist )) ) | 611 | ((stat_testing_hostlist == GNUNET_YES) && ( NULL != current_hostlist )) ) |
604 | { | 612 | { |
605 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 613 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
606 | "Updating hostlist statics for URI `%s'\n",current_hostlist->hostlist_uri ); | 614 | "Updating hostlist statics for URI `%s'\n",current_hostlist->hostlist_uri ); |
607 | current_hostlist->hello_count = hellos_obtained; | 615 | current_hostlist->hello_count = stat_hellos_obtained; |
608 | current_hostlist->time_last_usage = GNUNET_TIME_absolute_get(); | 616 | current_hostlist->time_last_usage = GNUNET_TIME_absolute_get(); |
609 | current_hostlist->quality = checked_add ( current_hostlist->quality, (hellos_obtained * HOSTLIST_SUCCESSFUL_HELLO)); | 617 | current_hostlist->quality = checked_add ( current_hostlist->quality, (stat_hellos_obtained * HOSTLIST_SUCCESSFUL_HELLO)); |
610 | if ( GNUNET_YES == download_successful ) | 618 | if ( GNUNET_YES == stat_download_successful ) |
611 | { | 619 | { |
612 | current_hostlist->times_used++; | 620 | current_hostlist->times_used++; |
613 | current_hostlist->quality = checked_add ( current_hostlist->quality, HOSTLIST_SUCCESSFUL_DOWNLOAD); | 621 | current_hostlist->quality = checked_add ( current_hostlist->quality, HOSTLIST_SUCCESSFUL_DOWNLOAD); |
@@ -627,18 +635,18 @@ static void update_hostlist ( ) | |||
627 | current_hostlist = NULL; | 635 | current_hostlist = NULL; |
628 | /* Alternating the usage of preconfigured and learned hostlists */ | 636 | /* Alternating the usage of preconfigured and learned hostlists */ |
629 | 637 | ||
630 | if (testing_hostlist == GNUNET_YES) | 638 | if (stat_testing_hostlist == GNUNET_YES) |
631 | return; | 639 | return; |
632 | 640 | ||
633 | if ( GNUNET_YES == learning) | 641 | if ( GNUNET_YES == stat_learning) |
634 | { | 642 | { |
635 | if (use_preconfigured_list == GNUNET_YES) | 643 | if (stat_use_bootstrap == GNUNET_YES) |
636 | use_preconfigured_list = GNUNET_NO; | 644 | stat_use_bootstrap = GNUNET_NO; |
637 | else | 645 | else |
638 | use_preconfigured_list = GNUNET_YES; | 646 | stat_use_bootstrap = GNUNET_YES; |
639 | } | 647 | } |
640 | else | 648 | else |
641 | use_preconfigured_list = GNUNET_YES; | 649 | stat_use_bootstrap = GNUNET_YES; |
642 | } | 650 | } |
643 | 651 | ||
644 | /** | 652 | /** |
@@ -650,15 +658,15 @@ clean_up () | |||
650 | { | 658 | { |
651 | CURLMcode mret; | 659 | CURLMcode mret; |
652 | 660 | ||
653 | if ( ( testing_hostlist == GNUNET_YES ) && ( GNUNET_NO == download_successful) && (NULL != hostlist_to_test)) | 661 | if ( ( stat_testing_hostlist == GNUNET_YES ) && ( GNUNET_NO == stat_download_successful) && (NULL != hostlist_to_test)) |
654 | { | 662 | { |
655 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 663 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
656 | _("Advertised hostlist with URI `%s' could not be downloaded. Advertised URI gets dismissed.\n"),hostlist_to_test->hostlist_uri); | 664 | _("Advertised hostlist with URI `%s' could not be downloaded. Advertised URI gets dismissed.\n"),hostlist_to_test->hostlist_uri); |
657 | } | 665 | } |
658 | 666 | ||
659 | if ( testing_hostlist == GNUNET_YES ) | 667 | if ( stat_testing_hostlist == GNUNET_YES ) |
660 | { | 668 | { |
661 | testing_hostlist = GNUNET_NO; | 669 | stat_testing_hostlist = GNUNET_NO; |
662 | } | 670 | } |
663 | if ( NULL != hostlist_to_test) | 671 | if ( NULL != hostlist_to_test) |
664 | { | 672 | { |
@@ -693,7 +701,7 @@ clean_up () | |||
693 | GNUNET_free_non_null (current_url); | 701 | GNUNET_free_non_null (current_url); |
694 | current_url = NULL; | 702 | current_url = NULL; |
695 | 703 | ||
696 | download_in_progress = GNUNET_NO; | 704 | stat_download_in_progress = GNUNET_NO; |
697 | } | 705 | } |
698 | 706 | ||
699 | /** | 707 | /** |
@@ -704,7 +712,7 @@ clean_up () | |||
704 | * @param tc task context, unused | 712 | * @param tc task context, unused |
705 | */ | 713 | */ |
706 | static void | 714 | static void |
707 | multi_ready (void *cls, | 715 | task_download (void *cls, |
708 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 716 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
709 | 717 | ||
710 | /** | 718 | /** |
@@ -712,7 +720,7 @@ multi_ready (void *cls, | |||
712 | * receiving task with the scheduler. | 720 | * receiving task with the scheduler. |
713 | */ | 721 | */ |
714 | static void | 722 | static void |
715 | run_multi () | 723 | download_prepare () |
716 | { | 724 | { |
717 | CURLMcode mret; | 725 | CURLMcode mret; |
718 | fd_set rs; | 726 | fd_set rs; |
@@ -766,7 +774,7 @@ run_multi () | |||
766 | rtime, | 774 | rtime, |
767 | grs, | 775 | grs, |
768 | gws, | 776 | gws, |
769 | &multi_ready, | 777 | &task_download, |
770 | multi); | 778 | multi); |
771 | GNUNET_NETWORK_fdset_destroy (gws); | 779 | GNUNET_NETWORK_fdset_destroy (gws); |
772 | GNUNET_NETWORK_fdset_destroy (grs); | 780 | GNUNET_NETWORK_fdset_destroy (grs); |
@@ -781,7 +789,7 @@ run_multi () | |||
781 | * @param tc task context, unused | 789 | * @param tc task context, unused |
782 | */ | 790 | */ |
783 | static void | 791 | static void |
784 | multi_ready (void *cls, | 792 | task_download (void *cls, |
785 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 793 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
786 | { | 794 | { |
787 | unsigned int counter; | 795 | unsigned int counter; |
@@ -847,15 +855,15 @@ multi_ready (void *cls, | |||
847 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 855 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
848 | _("Download of hostlist `%s' completed.\n"), | 856 | _("Download of hostlist `%s' completed.\n"), |
849 | current_url); | 857 | current_url); |
850 | download_successful = GNUNET_YES; | 858 | stat_download_successful = GNUNET_YES; |
851 | update_hostlist(); | 859 | update_hostlist(); |
852 | if (GNUNET_YES == testing_hostlist) | 860 | if (GNUNET_YES == stat_testing_hostlist) |
853 | { | 861 | { |
854 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 862 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
855 | _("Adding successfully tested hostlist `%s' datastore.\n"),current_url); | 863 | _("Adding successfully tested hostlist `%s' datastore.\n"),current_url); |
856 | insert_hostlist(); | 864 | insert_hostlist(); |
857 | hostlist_to_test = NULL; | 865 | hostlist_to_test = NULL; |
858 | testing_hostlist = GNUNET_NO; | 866 | stat_testing_hostlist = GNUNET_NO; |
859 | } | 867 | } |
860 | } | 868 | } |
861 | clean_up (); | 869 | clean_up (); |
@@ -877,7 +885,7 @@ multi_ready (void *cls, | |||
877 | curl_multi_strerror (mret)); | 885 | curl_multi_strerror (mret)); |
878 | clean_up (); | 886 | clean_up (); |
879 | } | 887 | } |
880 | run_multi (); | 888 | download_prepare (); |
881 | } | 889 | } |
882 | 890 | ||
883 | 891 | ||
@@ -892,7 +900,7 @@ download_hostlist () | |||
892 | CURLMcode mret; | 900 | CURLMcode mret; |
893 | 901 | ||
894 | 902 | ||
895 | current_url = get_list_url (); | 903 | current_url = download_get_url (); |
896 | if (current_url == NULL) | 904 | if (current_url == NULL) |
897 | return; | 905 | return; |
898 | curl = curl_easy_init (); | 906 | curl = curl_easy_init (); |
@@ -907,9 +915,9 @@ download_hostlist () | |||
907 | _("Bootstrapping using hostlist at `%s'.\n"), | 915 | _("Bootstrapping using hostlist at `%s'.\n"), |
908 | current_url); | 916 | current_url); |
909 | 917 | ||
910 | download_in_progress = GNUNET_YES; | 918 | stat_download_in_progress = GNUNET_YES; |
911 | download_successful = GNUNET_NO; | 919 | stat_download_successful = GNUNET_NO; |
912 | hellos_obtained = 0; | 920 | stat_hellos_obtained = 0; |
913 | 921 | ||
914 | GNUNET_STATISTICS_update (stats, | 922 | GNUNET_STATISTICS_update (stats, |
915 | gettext_noop ("# hostlist downloads initiated"), | 923 | gettext_noop ("# hostlist downloads initiated"), |
@@ -918,10 +926,10 @@ download_hostlist () | |||
918 | if (proxy != NULL) | 926 | if (proxy != NULL) |
919 | CURL_EASY_SETOPT (curl, CURLOPT_PROXY, proxy); | 927 | CURL_EASY_SETOPT (curl, CURLOPT_PROXY, proxy); |
920 | download_pos = 0; | 928 | download_pos = 0; |
921 | bogus_url = 0; | 929 | stat_bogus_url = 0; |
922 | CURL_EASY_SETOPT (curl, | 930 | CURL_EASY_SETOPT (curl, |
923 | CURLOPT_WRITEFUNCTION, | 931 | CURLOPT_WRITEFUNCTION, |
924 | &download_hostlist_processor); | 932 | &callback_download); |
925 | if (ret != CURLE_OK) | 933 | if (ret != CURLE_OK) |
926 | { | 934 | { |
927 | clean_up (); | 935 | clean_up (); |
@@ -996,12 +1004,12 @@ download_hostlist () | |||
996 | return; | 1004 | return; |
997 | } | 1005 | } |
998 | end_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); | 1006 | end_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); |
999 | run_multi (); | 1007 | download_prepare (); |
1000 | } | 1008 | } |
1001 | 1009 | ||
1002 | 1010 | ||
1003 | static void | 1011 | static void |
1004 | download_dispatcher (void *cls, | 1012 | task_download_dispatcher (void *cls, |
1005 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 1013 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
1006 | { | 1014 | { |
1007 | ti_download_dispatcher_task = GNUNET_SCHEDULER_NO_TASK; | 1015 | ti_download_dispatcher_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -1009,7 +1017,7 @@ download_dispatcher (void *cls, | |||
1009 | return; | 1017 | return; |
1010 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1018 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1011 | "Download is initiated...\n"); | 1019 | "Download is initiated...\n"); |
1012 | if ( GNUNET_NO == download_in_progress ) | 1020 | if ( GNUNET_NO == stat_download_in_progress ) |
1013 | { | 1021 | { |
1014 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1022 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1015 | "Download can start immediately...\n"); | 1023 | "Download can start immediately...\n"); |
@@ -1021,7 +1029,7 @@ download_dispatcher (void *cls, | |||
1021 | "Download in progess, have to wait...\n"); | 1029 | "Download in progess, have to wait...\n"); |
1022 | ti_download_dispatcher_task = GNUNET_SCHEDULER_add_delayed (sched, | 1030 | ti_download_dispatcher_task = GNUNET_SCHEDULER_add_delayed (sched, |
1023 | WAITING_INTERVALL, | 1031 | WAITING_INTERVALL, |
1024 | &download_dispatcher, | 1032 | &task_download_dispatcher, |
1025 | NULL); | 1033 | NULL); |
1026 | } | 1034 | } |
1027 | } | 1035 | } |
@@ -1032,17 +1040,17 @@ download_dispatcher (void *cls, | |||
1032 | * this task again for a later time. | 1040 | * this task again for a later time. |
1033 | */ | 1041 | */ |
1034 | static void | 1042 | static void |
1035 | check_task (void *cls, | 1043 | task_check (void *cls, |
1036 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 1044 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
1037 | { | 1045 | { |
1038 | ti_check_download = GNUNET_SCHEDULER_NO_TASK; | 1046 | ti_check_download = GNUNET_SCHEDULER_NO_TASK; |
1039 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1047 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
1040 | return; | 1048 | return; |
1041 | 1049 | ||
1042 | if (connection_count < MIN_CONNECTIONS) | 1050 | if (stat_connection_count < MIN_CONNECTIONS) |
1043 | { | 1051 | { |
1044 | ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now ( sched, | 1052 | ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now ( sched, |
1045 | &download_dispatcher, | 1053 | &task_download_dispatcher, |
1046 | NULL); | 1054 | NULL); |
1047 | } | 1055 | } |
1048 | 1056 | ||
@@ -1059,9 +1067,9 @@ check_task (void *cls, | |||
1059 | hostlist_delay = GNUNET_TIME_UNIT_SECONDS; | 1067 | hostlist_delay = GNUNET_TIME_UNIT_SECONDS; |
1060 | else | 1068 | else |
1061 | hostlist_delay = GNUNET_TIME_relative_multiply (hostlist_delay, 2); | 1069 | hostlist_delay = GNUNET_TIME_relative_multiply (hostlist_delay, 2); |
1062 | if (hostlist_delay.value > GNUNET_TIME_UNIT_HOURS.value * (1 + connection_count)) | 1070 | if (hostlist_delay.value > GNUNET_TIME_UNIT_HOURS.value * (1 + stat_connection_count)) |
1063 | hostlist_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, | 1071 | hostlist_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, |
1064 | (1 + connection_count)); | 1072 | (1 + stat_connection_count)); |
1065 | GNUNET_STATISTICS_set (stats, | 1073 | GNUNET_STATISTICS_set (stats, |
1066 | gettext_noop("# seconds between hostlist downloads"), | 1074 | gettext_noop("# seconds between hostlist downloads"), |
1067 | hostlist_delay.value, | 1075 | hostlist_delay.value, |
@@ -1073,12 +1081,12 @@ check_task (void *cls, | |||
1073 | } | 1081 | } |
1074 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1082 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1075 | _("Have %u/%u connections. Will consider downloading hostlist in %llums\n"), | 1083 | _("Have %u/%u connections. Will consider downloading hostlist in %llums\n"), |
1076 | connection_count, | 1084 | stat_connection_count, |
1077 | MIN_CONNECTIONS, | 1085 | MIN_CONNECTIONS, |
1078 | (unsigned long long) delay.value); | 1086 | (unsigned long long) delay.value); |
1079 | ti_check_download = GNUNET_SCHEDULER_add_delayed (sched, | 1087 | ti_check_download = GNUNET_SCHEDULER_add_delayed (sched, |
1080 | delay, | 1088 | delay, |
1081 | &check_task, | 1089 | &task_check, |
1082 | NULL); | 1090 | NULL); |
1083 | } | 1091 | } |
1084 | 1092 | ||
@@ -1094,7 +1102,7 @@ task_testing_intervall_reset (void *cls, | |||
1094 | ti_testing_intervall_task = GNUNET_SCHEDULER_NO_TASK; | 1102 | ti_testing_intervall_task = GNUNET_SCHEDULER_NO_TASK; |
1095 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1103 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
1096 | return; | 1104 | return; |
1097 | testing_allowed = GNUNET_OK; | 1105 | stat_testing_allowed = GNUNET_OK; |
1098 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1106 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1099 | "Testing new hostlist advertisements is allowed again\n"); | 1107 | "Testing new hostlist advertisements is allowed again\n"); |
1100 | } | 1108 | } |
@@ -1140,7 +1148,7 @@ handler_connect (void *cls, | |||
1140 | struct GNUNET_TIME_Relative latency, | 1148 | struct GNUNET_TIME_Relative latency, |
1141 | uint32_t distance) | 1149 | uint32_t distance) |
1142 | { | 1150 | { |
1143 | connection_count++; | 1151 | stat_connection_count++; |
1144 | GNUNET_STATISTICS_update (stats, | 1152 | GNUNET_STATISTICS_update (stats, |
1145 | gettext_noop ("# active connections"), | 1153 | gettext_noop ("# active connections"), |
1146 | 1, | 1154 | 1, |
@@ -1159,7 +1167,7 @@ handler_disconnect (void *cls, | |||
1159 | const struct | 1167 | const struct |
1160 | GNUNET_PeerIdentity * peer) | 1168 | GNUNET_PeerIdentity * peer) |
1161 | { | 1169 | { |
1162 | connection_count--; | 1170 | stat_connection_count--; |
1163 | GNUNET_STATISTICS_update (stats, | 1171 | GNUNET_STATISTICS_update (stats, |
1164 | gettext_noop ("# active connections"), | 1172 | gettext_noop ("# active connections"), |
1165 | -1, | 1173 | -1, |
@@ -1217,13 +1225,13 @@ handler_advertisement (void *cls, | |||
1217 | return GNUNET_OK; | 1225 | return GNUNET_OK; |
1218 | } | 1226 | } |
1219 | 1227 | ||
1220 | if ( GNUNET_NO == testing_allowed ) | 1228 | if ( GNUNET_NO == stat_testing_allowed ) |
1221 | { | 1229 | { |
1222 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1230 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1223 | "Currently not accepting new advertisements: interval between to advertisements is not reached\n"); | 1231 | "Currently not accepting new advertisements: interval between to advertisements is not reached\n"); |
1224 | return GNUNET_SYSERR; | 1232 | return GNUNET_SYSERR; |
1225 | } | 1233 | } |
1226 | if ( GNUNET_YES == testing_hostlist ) | 1234 | if ( GNUNET_YES == stat_testing_hostlist ) |
1227 | { | 1235 | { |
1228 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1236 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1229 | "Currently not accepting new advertisements: we are already testing a hostlist\n"); | 1237 | "Currently not accepting new advertisements: we are already testing a hostlist\n"); |
@@ -1238,8 +1246,8 @@ handler_advertisement (void *cls, | |||
1238 | hostlist->quality = HOSTLIST_INITIAL; | 1246 | hostlist->quality = HOSTLIST_INITIAL; |
1239 | hostlist_to_test = hostlist; | 1247 | hostlist_to_test = hostlist; |
1240 | 1248 | ||
1241 | testing_hostlist = GNUNET_YES; | 1249 | stat_testing_hostlist = GNUNET_YES; |
1242 | testing_allowed = GNUNET_NO; | 1250 | stat_testing_allowed = GNUNET_NO; |
1243 | ti_testing_intervall_task = GNUNET_SCHEDULER_add_delayed (sched, | 1251 | ti_testing_intervall_task = GNUNET_SCHEDULER_add_delayed (sched, |
1244 | TESTING_INTERVALL, | 1252 | TESTING_INTERVALL, |
1245 | &task_testing_intervall_reset, | 1253 | &task_testing_intervall_reset, |
@@ -1250,7 +1258,7 @@ handler_advertisement (void *cls, | |||
1250 | TESTING_INTERVALL); | 1258 | TESTING_INTERVALL); |
1251 | 1259 | ||
1252 | ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (sched, | 1260 | ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (sched, |
1253 | &download_dispatcher, | 1261 | &task_download_dispatcher, |
1254 | NULL); | 1262 | NULL); |
1255 | 1263 | ||
1256 | return GNUNET_OK; | 1264 | return GNUNET_OK; |
@@ -1276,7 +1284,7 @@ primary_task (void *cls, int success) | |||
1276 | "Statistics request done, scheduling hostlist download\n"); | 1284 | "Statistics request done, scheduling hostlist download\n"); |
1277 | #endif | 1285 | #endif |
1278 | ti_check_download = GNUNET_SCHEDULER_add_now (sched, | 1286 | ti_check_download = GNUNET_SCHEDULER_add_now (sched, |
1279 | &check_task, | 1287 | &task_check, |
1280 | NULL); | 1288 | NULL); |
1281 | } | 1289 | } |
1282 | 1290 | ||
@@ -1512,16 +1520,16 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1512 | "HTTP-PROXY", | 1520 | "HTTP-PROXY", |
1513 | &proxy)) | 1521 | &proxy)) |
1514 | proxy = NULL; | 1522 | proxy = NULL; |
1515 | learning = learn; | 1523 | stat_learning = learn; |
1516 | *ch = &handler_connect; | 1524 | *ch = &handler_connect; |
1517 | *dh = &handler_disconnect; | 1525 | *dh = &handler_disconnect; |
1518 | linked_list_head = NULL; | 1526 | linked_list_head = NULL; |
1519 | linked_list_tail = NULL; | 1527 | linked_list_tail = NULL; |
1520 | use_preconfigured_list = GNUNET_YES; | 1528 | stat_use_bootstrap = GNUNET_YES; |
1521 | testing_hostlist = GNUNET_NO; | 1529 | stat_testing_hostlist = GNUNET_NO; |
1522 | testing_allowed = GNUNET_YES; | 1530 | stat_testing_allowed = GNUNET_YES; |
1523 | 1531 | ||
1524 | if ( GNUNET_YES == learning ) | 1532 | if ( GNUNET_YES == stat_learning ) |
1525 | { | 1533 | { |
1526 | *msgh = &handler_advertisement; | 1534 | *msgh = &handler_advertisement; |
1527 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1535 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -1579,7 +1587,7 @@ GNUNET_HOSTLIST_client_stop () | |||
1579 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1587 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1580 | "Hostlist client shutdown\n"); | 1588 | "Hostlist client shutdown\n"); |
1581 | #endif | 1589 | #endif |
1582 | if ( GNUNET_YES == learning ) | 1590 | if ( GNUNET_YES == stat_learning ) |
1583 | save_hostlist_file ( GNUNET_YES ); | 1591 | save_hostlist_file ( GNUNET_YES ); |
1584 | 1592 | ||
1585 | if (ti_saving_task != GNUNET_SCHEDULER_NO_TASK) | 1593 | if (ti_saving_task != GNUNET_SCHEDULER_NO_TASK) |