diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-22 20:18:51 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-22 20:18:51 +0000 |
commit | c1ed03a28d6de09d7d0ac2025af9f8067e6bb0fd (patch) | |
tree | 88de639ea757a17285ef9ce4a4ac36e6100a16f0 /src | |
parent | edf96a3a7167f674cb69ef73b9abda8fec34f910 (diff) | |
download | gnunet-c1ed03a28d6de09d7d0ac2025af9f8067e6bb0fd.tar.gz gnunet-c1ed03a28d6de09d7d0ac2025af9f8067e6bb0fd.zip |
just indentation / formatting
Diffstat (limited to 'src')
-rw-r--r-- | src/hostlist/hostlist-client.c | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 049e78c52..f104e79d4 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c | |||
@@ -147,6 +147,7 @@ static CURLM *multi; | |||
147 | * How many bytes did we download from the current hostlist URL? | 147 | * How many bytes did we download from the current hostlist URL? |
148 | */ | 148 | */ |
149 | static uint32_t stat_bytes_downloaded; | 149 | static uint32_t stat_bytes_downloaded; |
150 | |||
150 | /** | 151 | /** |
151 | * Amount of time we wait between hostlist downloads. | 152 | * Amount of time we wait between hostlist downloads. |
152 | */ | 153 | */ |
@@ -263,9 +264,9 @@ static unsigned int stat_connection_count; | |||
263 | */ | 264 | */ |
264 | static size_t | 265 | static size_t |
265 | callback_download (void *ptr, | 266 | callback_download (void *ptr, |
266 | size_t size, | 267 | size_t size, |
267 | size_t nmemb, | 268 | size_t nmemb, |
268 | void *ctx) | 269 | void *ctx) |
269 | { | 270 | { |
270 | static char download_buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; | 271 | static char download_buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; |
271 | const char * cbuf = ptr; | 272 | const char * cbuf = ptr; |
@@ -462,7 +463,8 @@ download_get_url () | |||
462 | current_hostlist = NULL; | 463 | current_hostlist = NULL; |
463 | return get_bootstrap_server(); | 464 | return get_bootstrap_server(); |
464 | } | 465 | } |
465 | index = GNUNET_CRYPTO_random_u32 ( GNUNET_CRYPTO_QUALITY_WEAK, linked_list_size); | 466 | index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
467 | linked_list_size); | ||
466 | counter = 0; | 468 | counter = 0; |
467 | pos = linked_list_head; | 469 | pos = linked_list_head; |
468 | while ( counter < index ) | 470 | while ( counter < index ) |
@@ -479,12 +481,14 @@ download_get_url () | |||
479 | 481 | ||
480 | #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) | 482 | #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) |
481 | 483 | ||
484 | |||
482 | /** | 485 | /** |
483 | * Method to save hostlist to a file during hostlist client shutdown | 486 | * Method to save hostlist to a file during hostlist client shutdown |
484 | * @param shutdown set if called because of shutdown, entries in linked list will be destroyed | 487 | * @param shutdown set if called because of shutdown, entries in linked list will be destroyed |
485 | */ | 488 | */ |
486 | static void save_hostlist_file ( int shutdown ); | 489 | static void save_hostlist_file ( int shutdown ); |
487 | 490 | ||
491 | |||
488 | /** | 492 | /** |
489 | * add val2 to val1 with overflow check | 493 | * add val2 to val1 with overflow check |
490 | * @param val1 value 1 | 494 | * @param val1 value 1 |
@@ -512,7 +516,9 @@ static uint64_t checked_add (uint64_t val1, uint64_t val2) | |||
512 | * @param val2 value 2 | 516 | * @param val2 value 2 |
513 | * @return result | 517 | * @return result |
514 | */ | 518 | */ |
515 | static uint64_t checked_sub (uint64_t val1, uint64_t val2) | 519 | static uint64_t |
520 | checked_sub (uint64_t val1, | ||
521 | uint64_t val2) | ||
516 | { | 522 | { |
517 | if ( val1 <= val2) | 523 | if ( val1 <= val2) |
518 | return 0; | 524 | return 0; |
@@ -566,10 +572,12 @@ linked_list_get_lowest_quality ( ) | |||
566 | 572 | ||
567 | 573 | ||
568 | /** | 574 | /** |
569 | * Method to insert a hostlist into the datastore. If datastore contains maximum number of elements, the elements with lowest quality is dismissed | 575 | * Method to insert a hostlist into the datastore. If datastore |
576 | * contains maximum number of elements, the elements with lowest | ||
577 | * quality is dismissed | ||
570 | */ | 578 | */ |
571 | static void | 579 | static void |
572 | insert_hostlist ( ) | 580 | insert_hostlist () |
573 | { | 581 | { |
574 | struct Hostlist * lowest_quality; | 582 | struct Hostlist * lowest_quality; |
575 | 583 | ||
@@ -655,15 +663,18 @@ clean_up () | |||
655 | { | 663 | { |
656 | CURLMcode mret; | 664 | CURLMcode mret; |
657 | 665 | ||
658 | if ( ( stat_testing_hostlist == GNUNET_YES ) && ( GNUNET_NO == stat_download_successful) && (NULL != hostlist_to_test)) | 666 | if ( (stat_testing_hostlist == GNUNET_YES) && |
667 | (GNUNET_NO == stat_download_successful) && | ||
668 | (NULL != hostlist_to_test)) | ||
659 | { | 669 | { |
660 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 670 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
661 | _("Advertised hostlist with URI `%s' could not be downloaded. Advertised URI gets dismissed.\n"),hostlist_to_test->hostlist_uri); | 671 | _("Advertised hostlist with URI `%s' could not be downloaded. Advertised URI gets dismissed.\n"), |
672 | hostlist_to_test->hostlist_uri); | ||
662 | } | 673 | } |
663 | 674 | ||
664 | if ( stat_testing_hostlist == GNUNET_YES ) | 675 | if (stat_testing_hostlist == GNUNET_YES) |
665 | { | 676 | { |
666 | stat_testing_hostlist = GNUNET_NO; | 677 | stat_testing_hostlist = GNUNET_NO; |
667 | } | 678 | } |
668 | if ( NULL != hostlist_to_test) | 679 | if ( NULL != hostlist_to_test) |
669 | { | 680 | { |
@@ -700,6 +711,7 @@ clean_up () | |||
700 | stat_download_in_progress = GNUNET_NO; | 711 | stat_download_in_progress = GNUNET_NO; |
701 | } | 712 | } |
702 | 713 | ||
714 | |||
703 | /** | 715 | /** |
704 | * Task that is run when we are ready to receive more data from the hostlist | 716 | * Task that is run when we are ready to receive more data from the hostlist |
705 | * server. | 717 | * server. |
@@ -709,7 +721,8 @@ clean_up () | |||
709 | */ | 721 | */ |
710 | static void | 722 | static void |
711 | task_download (void *cls, | 723 | task_download (void *cls, |
712 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 724 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
725 | |||
713 | 726 | ||
714 | /** | 727 | /** |
715 | * Ask CURL for the select set and then schedule the | 728 | * Ask CURL for the select set and then schedule the |
@@ -785,9 +798,8 @@ download_prepare () | |||
785 | */ | 798 | */ |
786 | static void | 799 | static void |
787 | task_download (void *cls, | 800 | task_download (void *cls, |
788 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 801 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
789 | { | 802 | { |
790 | |||
791 | int running; | 803 | int running; |
792 | struct CURLMsg *msg; | 804 | struct CURLMsg *msg; |
793 | CURLMcode mret; | 805 | CURLMcode mret; |
@@ -824,7 +836,8 @@ task_download (void *cls, | |||
824 | if (stat_bytes_downloaded > MAX_BYTES_PER_HOSTLISTS) | 836 | if (stat_bytes_downloaded > MAX_BYTES_PER_HOSTLISTS) |
825 | { | 837 | { |
826 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 838 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
827 | _("Download limit of %u bytes exceeded, stopping download\n"),MAX_BYTES_PER_HOSTLISTS); | 839 | _("Download limit of %u bytes exceeded, stopping download\n"), |
840 | MAX_BYTES_PER_HOSTLISTS); | ||
828 | clean_up(); | 841 | clean_up(); |
829 | return; | 842 | return; |
830 | } | 843 | } |
@@ -833,8 +846,6 @@ task_download (void *cls, | |||
833 | { | 846 | { |
834 | do | 847 | do |
835 | { | 848 | { |
836 | |||
837 | |||
838 | msg = curl_multi_info_read (multi, &running); | 849 | msg = curl_multi_info_read (multi, &running); |
839 | GNUNET_break (msg != NULL); | 850 | GNUNET_break (msg != NULL); |
840 | if (msg == NULL) | 851 | if (msg == NULL) |
@@ -860,8 +871,9 @@ task_download (void *cls, | |||
860 | update_hostlist(); | 871 | update_hostlist(); |
861 | if (GNUNET_YES == stat_testing_hostlist) | 872 | if (GNUNET_YES == stat_testing_hostlist) |
862 | { | 873 | { |
863 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 874 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
864 | _("Adding successfully tested hostlist `%s' datastore.\n"),current_url); | 875 | _("Adding successfully tested hostlist `%s' datastore.\n"), |
876 | current_url); | ||
865 | insert_hostlist(); | 877 | insert_hostlist(); |
866 | hostlist_to_test = NULL; | 878 | hostlist_to_test = NULL; |
867 | stat_testing_hostlist = GNUNET_NO; | 879 | stat_testing_hostlist = GNUNET_NO; |
@@ -1090,10 +1102,12 @@ task_check (void *cls, | |||
1090 | NULL); | 1102 | NULL); |
1091 | } | 1103 | } |
1092 | 1104 | ||
1105 | |||
1093 | /** | 1106 | /** |
1094 | * This tasks sets hostlist testing to allowed after intervall between to testings is reached | 1107 | * This tasks sets hostlist testing to allowed after intervall between to testings is reached |
1095 | * cls closure | 1108 | * |
1096 | * tc TaskContext | 1109 | * @param cls closure |
1110 | * @param tc TaskContext | ||
1097 | */ | 1111 | */ |
1098 | static void | 1112 | static void |
1099 | task_testing_intervall_reset (void *cls, | 1113 | task_testing_intervall_reset (void *cls, |
@@ -1110,8 +1124,9 @@ task_testing_intervall_reset (void *cls, | |||
1110 | 1124 | ||
1111 | /** | 1125 | /** |
1112 | * Task that writes hostlist entries to a file on a regular base | 1126 | * Task that writes hostlist entries to a file on a regular base |
1113 | * cls closure | 1127 | * |
1114 | * tc TaskContext | 1128 | * @param cls closure |
1129 | * @param tc TaskContext | ||
1115 | */ | 1130 | */ |
1116 | static void | 1131 | static void |
1117 | task_hostlist_saving (void *cls, | 1132 | task_hostlist_saving (void *cls, |
@@ -1132,6 +1147,7 @@ task_hostlist_saving (void *cls, | |||
1132 | NULL); | 1147 | NULL); |
1133 | } | 1148 | } |
1134 | 1149 | ||
1150 | |||
1135 | /** | 1151 | /** |
1136 | * Method called whenever a given peer connects. | 1152 | * Method called whenever a given peer connects. |
1137 | * | 1153 | * |
@@ -1173,6 +1189,7 @@ handler_disconnect (void *cls, | |||
1173 | GNUNET_NO); | 1189 | GNUNET_NO); |
1174 | } | 1190 | } |
1175 | 1191 | ||
1192 | |||
1176 | /** | 1193 | /** |
1177 | * Method called whenever an advertisement message arrives. | 1194 | * Method called whenever an advertisement message arrives. |
1178 | * | 1195 | * |
@@ -1536,8 +1553,8 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1536 | _("Hostlists will be saved to file again in %llums\n"), | 1553 | _("Hostlists will be saved to file again in %llums\n"), |
1537 | (unsigned long long) SAVING_INTERVALL.rel_value); | 1554 | (unsigned long long) SAVING_INTERVALL.rel_value); |
1538 | ti_saving_task = GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, | 1555 | ti_saving_task = GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, |
1539 | &task_hostlist_saving, | 1556 | &task_hostlist_saving, |
1540 | NULL); | 1557 | NULL); |
1541 | } | 1558 | } |
1542 | else | 1559 | else |
1543 | { | 1560 | { |
@@ -1554,10 +1571,12 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1554 | result = remove (filename); | 1571 | result = remove (filename); |
1555 | if (result == 0) | 1572 | if (result == 0) |
1556 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1573 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1557 | _("Since learning is not enabled on this peer, hostlist file `%s' was removed\n"),filename); | 1574 | _("Since learning is not enabled on this peer, hostlist file `%s' was removed\n"), |
1575 | filename); | ||
1558 | else | 1576 | else |
1559 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1577 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1560 | _("Hostlist file `%s' could not be removed\n"),filename); | 1578 | _("Hostlist file `%s' could not be removed\n"), |
1579 | filename); | ||
1561 | } | 1580 | } |
1562 | } | 1581 | } |
1563 | GNUNET_free ( filename ); | 1582 | GNUNET_free ( filename ); |