diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-23 11:42:19 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-23 11:42:19 +0000 |
commit | 3dfbd2dbffb3fefe8a1e59088c12d42840a12311 (patch) | |
tree | 48f737a456d38a1eaefe850fea9452a9af5c525b /src/hostlist | |
parent | 6551b2bcb1207c3c8796859783b31c5388d0f719 (diff) | |
download | gnunet-3dfbd2dbffb3fefe8a1e59088c12d42840a12311.tar.gz gnunet-3dfbd2dbffb3fefe8a1e59088c12d42840a12311.zip |
Diffstat (limited to 'src/hostlist')
-rw-r--r-- | src/hostlist/hostlist-client.c | 81 | ||||
-rw-r--r-- | src/hostlist/test_gnunet_daemon_hostlist_learning.c | 2 |
2 files changed, 30 insertions, 53 deletions
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 5d3da4864..54fb8db27 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c | |||
@@ -456,14 +456,6 @@ get_list_url () | |||
456 | 456 | ||
457 | #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); | 457 | #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); |
458 | 458 | ||
459 | |||
460 | /** | ||
461 | * Schedule the background task that will (possibly) | ||
462 | * download a hostlist. | ||
463 | */ | ||
464 | static void | ||
465 | schedule_hostlist_task (void); | ||
466 | |||
467 | /** | 459 | /** |
468 | * Method to load persistent hostlist file during hostlist client shutdown | 460 | * Method to load persistent hostlist file during hostlist client shutdown |
469 | * @param shutdown set if called because of shutdown, entries in linked list will be destroyed | 461 | * @param shutdown set if called because of shutdown, entries in linked list will be destroyed |
@@ -610,8 +602,6 @@ static void update_hostlist ( ) | |||
610 | GNUNET_asprintf (&stat, | 602 | GNUNET_asprintf (&stat, |
611 | gettext_noop("# advertised URI `%s' downloaded"), | 603 | gettext_noop("# advertised URI `%s' downloaded"), |
612 | current_hostlist->hostlist_uri); | 604 | current_hostlist->hostlist_uri); |
613 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
614 | "Updating downloaded statics for URI to value\n" ); | ||
615 | 605 | ||
616 | GNUNET_STATISTICS_update ( stats, | 606 | GNUNET_STATISTICS_update ( stats, |
617 | stat, | 607 | stat, |
@@ -822,15 +812,6 @@ multi_ready (void *cls, | |||
822 | { | 812 | { |
823 | 813 | ||
824 | msg = curl_multi_info_read (multi, &running); | 814 | msg = curl_multi_info_read (multi, &running); |
825 | /* | ||
826 | if (counter >= MAX_HELLO_PER_HOSTLISTS) | ||
827 | { | ||
828 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
829 | _("Maximum number of %u HELLOs per hostlist exceeded, stopping download...\n"), | ||
830 | MAX_HELLO_PER_HOSTLISTS); | ||
831 | clean_up (); | ||
832 | break; | ||
833 | }*/ | ||
834 | counter ++; | 815 | counter ++; |
835 | GNUNET_break (msg != NULL); | 816 | GNUNET_break (msg != NULL); |
836 | if (msg == NULL) | 817 | if (msg == NULL) |
@@ -896,7 +877,6 @@ download_hostlist () | |||
896 | CURLcode ret; | 877 | CURLcode ret; |
897 | CURLMcode mret; | 878 | CURLMcode mret; |
898 | 879 | ||
899 | download_in_progress = GNUNET_YES; | ||
900 | 880 | ||
901 | current_url = get_list_url (); | 881 | current_url = get_list_url (); |
902 | if (current_url == NULL) | 882 | if (current_url == NULL) |
@@ -912,8 +892,11 @@ download_hostlist () | |||
912 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, | 892 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, |
913 | _("Bootstrapping using hostlist at `%s'.\n"), | 893 | _("Bootstrapping using hostlist at `%s'.\n"), |
914 | current_url); | 894 | current_url); |
915 | hellos_obtained = 0; | 895 | |
896 | download_in_progress = GNUNET_YES; | ||
916 | download_successful = GNUNET_NO; | 897 | download_successful = GNUNET_NO; |
898 | hellos_obtained = 0; | ||
899 | |||
917 | GNUNET_STATISTICS_update (stats, | 900 | GNUNET_STATISTICS_update (stats, |
918 | gettext_noop ("# hostlist downloads initiated"), | 901 | gettext_noop ("# hostlist downloads initiated"), |
919 | 1, | 902 | 1, |
@@ -1038,27 +1021,14 @@ check_task (void *cls, | |||
1038 | current_task = GNUNET_SCHEDULER_NO_TASK; | 1021 | current_task = GNUNET_SCHEDULER_NO_TASK; |
1039 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1022 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
1040 | return; | 1023 | return; |
1041 | /*if ( GNUNET_YES == testing_hostlist ) | 1024 | |
1042 | download_hostlist();*/ | ||
1043 | if (connection_count < MIN_CONNECTIONS) | 1025 | if (connection_count < MIN_CONNECTIONS) |
1044 | { | 1026 | { |
1045 | GNUNET_SCHEDULER_add_now (sched, | 1027 | GNUNET_SCHEDULER_add_now (sched, |
1046 | &download_dispatcher, | 1028 | &download_dispatcher, |
1047 | NULL); | 1029 | NULL); |
1048 | schedule_hostlist_task (); | ||
1049 | } | 1030 | } |
1050 | else | ||
1051 | schedule_hostlist_task (); | ||
1052 | } | ||
1053 | 1031 | ||
1054 | |||
1055 | /** | ||
1056 | * Compute when we should check the next time about downloading | ||
1057 | * a hostlist; then schedule the task accordingly. | ||
1058 | */ | ||
1059 | static void | ||
1060 | schedule_hostlist_task () | ||
1061 | { | ||
1062 | static int once; | 1032 | static int once; |
1063 | struct GNUNET_TIME_Relative delay; | 1033 | struct GNUNET_TIME_Relative delay; |
1064 | 1034 | ||
@@ -1074,25 +1044,25 @@ schedule_hostlist_task () | |||
1074 | hostlist_delay = GNUNET_TIME_relative_multiply (hostlist_delay, 2); | 1044 | hostlist_delay = GNUNET_TIME_relative_multiply (hostlist_delay, 2); |
1075 | if (hostlist_delay.value > GNUNET_TIME_UNIT_HOURS.value * (1 + connection_count)) | 1045 | if (hostlist_delay.value > GNUNET_TIME_UNIT_HOURS.value * (1 + connection_count)) |
1076 | hostlist_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, | 1046 | hostlist_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, |
1077 | (1 + connection_count)); | 1047 | (1 + connection_count)); |
1078 | GNUNET_STATISTICS_set (stats, | 1048 | GNUNET_STATISTICS_set (stats, |
1079 | gettext_noop("# seconds between hostlist downloads"), | 1049 | gettext_noop("# seconds between hostlist downloads"), |
1080 | hostlist_delay.value, | 1050 | hostlist_delay.value, |
1081 | GNUNET_YES); | 1051 | GNUNET_YES); |
1082 | if (0 == once) | 1052 | if (0 == once) |
1083 | { | 1053 | { |
1084 | delay = GNUNET_TIME_UNIT_ZERO; | 1054 | delay = GNUNET_TIME_UNIT_ZERO; |
1085 | once = 1; | 1055 | once = 1; |
1086 | } | 1056 | } |
1087 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1057 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1088 | _("Have %u/%u connections. Will consider downloading hostlist in %llums\n"), | 1058 | _("Have %u/%u connections. Will consider downloading hostlist in %llums\n"), |
1089 | connection_count, | 1059 | connection_count, |
1090 | MIN_CONNECTIONS, | 1060 | MIN_CONNECTIONS, |
1091 | (unsigned long long) delay.value); | 1061 | (unsigned long long) delay.value); |
1092 | current_task = GNUNET_SCHEDULER_add_delayed (sched, | 1062 | current_task = GNUNET_SCHEDULER_add_delayed (sched, |
1093 | delay, | 1063 | delay, |
1094 | &check_task, | 1064 | &check_task, |
1095 | NULL); | 1065 | NULL); |
1096 | } | 1066 | } |
1097 | 1067 | ||
1098 | /** | 1068 | /** |
@@ -1227,11 +1197,17 @@ advertisement_handler (void *cls, | |||
1227 | return GNUNET_OK; | 1197 | return GNUNET_OK; |
1228 | } | 1198 | } |
1229 | 1199 | ||
1230 | if ( (GNUNET_YES == testing_hostlist) || ( GNUNET_NO == testing_allowed) ) | 1200 | if ( GNUNET_NO == testing_allowed ) |
1231 | { | 1201 | { |
1232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1202 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1233 | "Currently not accepting adverts\n"); | 1203 | "Currently not accepting new advertisements: interval between to advertisements is not reached\n"); |
1234 | return GNUNET_OK; | 1204 | return GNUNET_SYSERR; |
1205 | } | ||
1206 | if ( GNUNET_YES == testing_hostlist ) | ||
1207 | { | ||
1208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1209 | "Currently not accepting new advertisements: we are already testing a hostlist\n"); | ||
1210 | return GNUNET_SYSERR; | ||
1235 | } | 1211 | } |
1236 | 1212 | ||
1237 | hostlist = GNUNET_malloc (sizeof (struct Hostlist) + uri_size); | 1213 | hostlist = GNUNET_malloc (sizeof (struct Hostlist) + uri_size); |
@@ -1250,10 +1226,9 @@ advertisement_handler (void *cls, | |||
1250 | NULL); | 1226 | NULL); |
1251 | 1227 | ||
1252 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1228 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1253 | "Testing new hostlist advertisements is locked for the next %u seconds\n", | 1229 | "Testing new hostlist advertisements is locked for the next %u ms\n", |
1254 | TESTING_INTERVALL); | 1230 | TESTING_INTERVALL); |
1255 | 1231 | ||
1256 | /* initiate download */ | ||
1257 | testing_intervall_task = GNUNET_SCHEDULER_add_now (sched, | 1232 | testing_intervall_task = GNUNET_SCHEDULER_add_now (sched, |
1258 | &download_dispatcher, | 1233 | &download_dispatcher, |
1259 | NULL); | 1234 | NULL); |
@@ -1280,7 +1255,9 @@ primary_task (void *cls, int success) | |||
1280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1255 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1281 | "Statistics request done, scheduling hostlist download\n"); | 1256 | "Statistics request done, scheduling hostlist download\n"); |
1282 | #endif | 1257 | #endif |
1283 | schedule_hostlist_task (); | 1258 | current_task = GNUNET_SCHEDULER_add_now (sched, |
1259 | &check_task, | ||
1260 | NULL); | ||
1284 | } | 1261 | } |
1285 | 1262 | ||
1286 | 1263 | ||
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c index a2fd126b7..b529eb86d 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c | |||
@@ -309,7 +309,7 @@ static int ad_arrive_handler (void *cls, | |||
309 | if ( 0 == strcmp( expected_uri, current_adv_uri ) ) | 309 | if ( 0 == strcmp( expected_uri, current_adv_uri ) ) |
310 | { | 310 | { |
311 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 311 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
312 | "Recieved hostlist advertisement with URI `%s'as expected\n", current_adv_uri); | 312 | "Recieved hostlist advertisement with URI `%s' as expected\n", current_adv_uri); |
313 | adv_arrived = GNUNET_YES; | 313 | adv_arrived = GNUNET_YES; |
314 | } | 314 | } |
315 | else | 315 | else |