diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-09-27 19:36:14 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-09-27 19:36:14 +0000 |
commit | 9cefd9c5522797b132749ca7d99a930007d28347 (patch) | |
tree | 63aa5de219bbd5f0d23f5f0affd418eee5bdd494 /src/hostlist | |
parent | a6a4bf9797ecf078179a102f52d1e30a4987bf03 (diff) | |
download | gnunet-9cefd9c5522797b132749ca7d99a930007d28347.tar.gz gnunet-9cefd9c5522797b132749ca7d99a930007d28347.zip |
-converting more places to use STRINGS_relative_time_to_string
Diffstat (limited to 'src/hostlist')
-rw-r--r-- | src/hostlist/hostlist-client.c | 63 | ||||
-rw-r--r-- | src/hostlist/hostlist-server.c | 6 |
2 files changed, 31 insertions, 38 deletions
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index e85c3cae7..69d7b873e 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c | |||
@@ -370,10 +370,8 @@ get_bootstrap_server () | |||
370 | GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", "SERVERS", | 370 | GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", "SERVERS", |
371 | &servers)) | 371 | &servers)) |
372 | { | 372 | { |
373 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 373 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, |
374 | _ | 374 | "hostlist", "SERVERS"); |
375 | ("No `%s' specified in `%s' configuration, will not bootstrap.\n"), | ||
376 | "SERVERS", "HOSTLIST"); | ||
377 | return NULL; | 375 | return NULL; |
378 | } | 376 | } |
379 | 377 | ||
@@ -391,10 +389,8 @@ get_bootstrap_server () | |||
391 | } | 389 | } |
392 | if (urls == 0) | 390 | if (urls == 0) |
393 | { | 391 | { |
394 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 392 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, |
395 | _ | 393 | "hostlist", "SERVERS"); |
396 | ("No `%s' specified in `%s' configuration, will not bootstrap.\n"), | ||
397 | "SERVERS", "HOSTLIST"); | ||
398 | GNUNET_free (servers); | 394 | GNUNET_free (servers); |
399 | return NULL; | 395 | return NULL; |
400 | } | 396 | } |
@@ -499,10 +495,10 @@ checked_add (uint64_t val1, uint64_t val2) | |||
499 | temp = val1 + val2; | 495 | temp = val1 + val2; |
500 | if (temp < val1) | 496 | if (temp < val1) |
501 | return maxv; | 497 | return maxv; |
502 | else | 498 | return temp; |
503 | return temp; | ||
504 | } | 499 | } |
505 | 500 | ||
501 | |||
506 | /** | 502 | /** |
507 | * Subtract val2 from val1 with underflow check | 503 | * Subtract val2 from val1 with underflow check |
508 | * @param val1 value 1 | 504 | * @param val1 value 1 |
@@ -514,10 +510,10 @@ checked_sub (uint64_t val1, uint64_t val2) | |||
514 | { | 510 | { |
515 | if (val1 <= val2) | 511 | if (val1 <= val2) |
516 | return 0; | 512 | return 0; |
517 | else | 513 | return (val1 - val2); |
518 | return (val1 - val2); | ||
519 | } | 514 | } |
520 | 515 | ||
516 | |||
521 | /** | 517 | /** |
522 | * Method to check if a URI is in hostlist linked list | 518 | * Method to check if a URI is in hostlist linked list |
523 | * @param uri uri to check | 519 | * @param uri uri to check |
@@ -647,6 +643,7 @@ update_hostlist () | |||
647 | stat_use_bootstrap = GNUNET_YES; | 643 | stat_use_bootstrap = GNUNET_YES; |
648 | } | 644 | } |
649 | 645 | ||
646 | |||
650 | /** | 647 | /** |
651 | * Clean up the state from the task that downloaded the | 648 | * Clean up the state from the task that downloaded the |
652 | * hostlist and schedule the next task. | 649 | * hostlist and schedule the next task. |
@@ -998,6 +995,7 @@ task_download_dispatcher (void *cls, | |||
998 | } | 995 | } |
999 | } | 996 | } |
1000 | 997 | ||
998 | |||
1001 | /** | 999 | /** |
1002 | * Task that checks if we should try to download a hostlist. | 1000 | * Task that checks if we should try to download a hostlist. |
1003 | * If so, we initiate the download, otherwise we schedule | 1001 | * If so, we initiate the download, otherwise we schedule |
@@ -1042,10 +1040,9 @@ task_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1042 | once = 1; | 1040 | once = 1; |
1043 | } | 1041 | } |
1044 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1042 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1045 | _ | 1043 | _("Have %u/%u connections. Will consider downloading hostlist in %s\n"), |
1046 | ("Have %u/%u connections. Will consider downloading hostlist in %llums\n"), | ||
1047 | stat_connection_count, MIN_CONNECTIONS, | 1044 | stat_connection_count, MIN_CONNECTIONS, |
1048 | (unsigned long long) delay.rel_value); | 1045 | GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); |
1049 | ti_check_download = GNUNET_SCHEDULER_add_delayed (delay, &task_check, NULL); | 1046 | ti_check_download = GNUNET_SCHEDULER_add_delayed (delay, &task_check, NULL); |
1050 | } | 1047 | } |
1051 | 1048 | ||
@@ -1081,12 +1078,11 @@ task_hostlist_saving (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1081 | ti_saving_task = GNUNET_SCHEDULER_NO_TASK; | 1078 | ti_saving_task = GNUNET_SCHEDULER_NO_TASK; |
1082 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1079 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
1083 | return; | 1080 | return; |
1084 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Scheduled saving of hostlists\n")); | ||
1085 | save_hostlist_file (GNUNET_NO); | 1081 | save_hostlist_file (GNUNET_NO); |
1086 | 1082 | ||
1087 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1083 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1088 | _("Hostlists will be saved to file again in %llums\n"), | 1084 | "Hostlists will be saved to file again in %s\n", |
1089 | (unsigned long long) SAVING_INTERVALL.rel_value); | 1085 | GNUNET_STRINGS_relative_time_to_string(SAVING_INTERVALL, GNUNET_YES)); |
1090 | ti_saving_task = | 1086 | ti_saving_task = |
1091 | GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving, | 1087 | GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving, |
1092 | NULL); | 1088 | NULL); |
@@ -1214,7 +1210,6 @@ handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1214 | } | 1210 | } |
1215 | 1211 | ||
1216 | 1212 | ||
1217 | |||
1218 | /** | 1213 | /** |
1219 | * Continuation called by the statistics code once | 1214 | * Continuation called by the statistics code once |
1220 | * we go the stat. Initiates hostlist download scheduling. | 1215 | * we go the stat. Initiates hostlist download scheduling. |
@@ -1238,13 +1233,14 @@ static int | |||
1238 | process_stat (void *cls, const char *subsystem, const char *name, | 1233 | process_stat (void *cls, const char *subsystem, const char *name, |
1239 | uint64_t value, int is_persistent) | 1234 | uint64_t value, int is_persistent) |
1240 | { | 1235 | { |
1241 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1242 | _("Initial time between hostlist downloads is %llums\n"), | ||
1243 | (unsigned long long) value); | ||
1244 | hostlist_delay.rel_value = value; | 1236 | hostlist_delay.rel_value = value; |
1237 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1238 | "Initial time between hostlist downloads is %s\n", | ||
1239 | GNUNET_STRINGS_relative_time_to_string (hostlist_delay, GNUNET_YES)); | ||
1245 | return GNUNET_OK; | 1240 | return GNUNET_OK; |
1246 | } | 1241 | } |
1247 | 1242 | ||
1243 | |||
1248 | /** | 1244 | /** |
1249 | * Method to load persistent hostlist file during hostlist client startup | 1245 | * Method to load persistent hostlist file during hostlist client startup |
1250 | */ | 1246 | */ |
@@ -1268,10 +1264,8 @@ load_hostlist_file () | |||
1268 | GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE", | 1264 | GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE", |
1269 | &filename)) | 1265 | &filename)) |
1270 | { | 1266 | { |
1271 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1267 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, |
1272 | _ | 1268 | "hostlist", "HOSTLISTFILE"); |
1273 | ("No `%s' specified in `%s' configuration, cannot load hostlists from file.\n"), | ||
1274 | "HOSTLISTFILE", "HOSTLIST"); | ||
1275 | return; | 1269 | return; |
1276 | } | 1270 | } |
1277 | 1271 | ||
@@ -1280,7 +1274,7 @@ load_hostlist_file () | |||
1280 | if (GNUNET_NO == GNUNET_DISK_file_test (filename)) | 1274 | if (GNUNET_NO == GNUNET_DISK_file_test (filename)) |
1281 | { | 1275 | { |
1282 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1276 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1283 | _("Hostlist file `%s' is not existing\n"), filename); | 1277 | _("Hostlist file `%s' does not exist\n"), filename); |
1284 | GNUNET_free (filename); | 1278 | GNUNET_free (filename); |
1285 | return; | 1279 | return; |
1286 | } | 1280 | } |
@@ -1357,10 +1351,8 @@ save_hostlist_file (int shutdown) | |||
1357 | GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE", | 1351 | GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE", |
1358 | &filename)) | 1352 | &filename)) |
1359 | { | 1353 | { |
1360 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1354 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, |
1361 | _ | 1355 | "hostlist", "HOSTLISTFILE"); |
1362 | ("No `%s' specified in `%s' configuration, cannot save hostlists to file.\n"), | ||
1363 | "HOSTLISTFILE", "HOSTLIST"); | ||
1364 | return; | 1356 | return; |
1365 | } | 1357 | } |
1366 | if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename)) | 1358 | if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename)) |
@@ -1423,6 +1415,7 @@ save_hostlist_file (int shutdown) | |||
1423 | GNUNET_free (filename); | 1415 | GNUNET_free (filename); |
1424 | } | 1416 | } |
1425 | 1417 | ||
1418 | |||
1426 | /** | 1419 | /** |
1427 | * Start downloading hostlists from hostlist servers as necessary. | 1420 | * Start downloading hostlists from hostlist servers as necessary. |
1428 | */ | 1421 | */ |
@@ -1469,9 +1462,9 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1469 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1462 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1470 | _("Learning is enabled on this peer\n")); | 1463 | _("Learning is enabled on this peer\n")); |
1471 | load_hostlist_file (); | 1464 | load_hostlist_file (); |
1472 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1465 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1473 | _("Hostlists will be saved to file again in %llums\n"), | 1466 | "Hostlists will be saved to file again in %s\n", |
1474 | (unsigned long long) SAVING_INTERVALL.rel_value); | 1467 | GNUNET_STRINGS_relative_time_to_string (SAVING_INTERVALL, GNUNET_YES)); |
1475 | ti_saving_task = | 1468 | ti_saving_task = |
1476 | GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving, | 1469 | GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving, |
1477 | NULL); | 1470 | NULL); |
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c index 0b82b7d1f..04da6e930 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c | |||
@@ -180,7 +180,7 @@ host_processor (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
180 | { | 180 | { |
181 | GNUNET_assert (NULL == peer); | 181 | GNUNET_assert (NULL == peer); |
182 | pitr = NULL; | 182 | pitr = NULL; |
183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 183 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
184 | _("Error in communication with PEERINFO service: %s\n"), | 184 | _("Error in communication with PEERINFO service: %s\n"), |
185 | err_msg); | 185 | err_msg); |
186 | return; | 186 | return; |
@@ -270,7 +270,7 @@ access_handler_callback (void *cls, struct MHD_Connection *connection, | |||
270 | if (NULL == *con_cls) | 270 | if (NULL == *con_cls) |
271 | { | 271 | { |
272 | (*con_cls) = &dummy; | 272 | (*con_cls) = &dummy; |
273 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Sending 100 CONTINUE reply\n")); | 273 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending 100 CONTINUE reply\n"); |
274 | return MHD_YES; /* send 100 continue */ | 274 | return MHD_YES; /* send 100 continue */ |
275 | } | 275 | } |
276 | if (0 != *upload_data_size) | 276 | if (0 != *upload_data_size) |
@@ -421,7 +421,7 @@ process_notify (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
422 | "Peerinfo is notifying us to rebuild our hostlist\n"); | 422 | "Peerinfo is notifying us to rebuild our hostlist\n"); |
423 | if (NULL != err_msg) | 423 | if (NULL != err_msg) |
424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 424 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
425 | _("Error in communication with PEERINFO service: %s\n"), | 425 | _("Error in communication with PEERINFO service: %s\n"), |
426 | err_msg); | 426 | err_msg); |
427 | if (NULL != pitr) | 427 | if (NULL != pitr) |