aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-10-27 09:48:46 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-10-27 09:48:46 +0000
commitba9ef31948175e08469403cfd8840db7efe5886f (patch)
treeafff54135d797e25c3c1819e67e8be0adc7f9ec1 /src
parent92ea81543438aebee77ceec02800da3e4da6a421 (diff)
downloadgnunet-ba9ef31948175e08469403cfd8840db7efe5886f.tar.gz
gnunet-ba9ef31948175e08469403cfd8840db7efe5886f.zip
Refactoring gnunet time
Diffstat (limited to 'src')
-rw-r--r--src/hello/hello.c18
-rw-r--r--src/hostlist/hostlist-client.c26
-rw-r--r--src/hostlist/hostlist-server.c4
3 files changed, 24 insertions, 24 deletions
diff --git a/src/hello/hello.c b/src/hello/hello.c
index 14a9e58be..9affad3c1 100644
--- a/src/hello/hello.c
+++ b/src/hello/hello.c
@@ -329,8 +329,8 @@ copy_latest (void *cls,
329 ec.tname = tname; 329 ec.tname = tname;
330 GNUNET_HELLO_iterate_addresses (mc->other, GNUNET_NO, &get_match_exp, &ec); 330 GNUNET_HELLO_iterate_addresses (mc->other, GNUNET_NO, &get_match_exp, &ec);
331 if ( (ec.found == GNUNET_NO) || 331 if ( (ec.found == GNUNET_NO) ||
332 (ec.expiration.value < expiration.value) || 332 (ec.expiration.abs_value < expiration.abs_value) ||
333 ( (ec.expiration.value == expiration.value) && 333 ( (ec.expiration.abs_value == expiration.abs_value) &&
334 (mc->take_equal == GNUNET_YES) ) ) 334 (mc->take_equal == GNUNET_YES) ) )
335 { 335 {
336 mc->ret += GNUNET_HELLO_add_address (tname, 336 mc->ret += GNUNET_HELLO_add_address (tname,
@@ -413,8 +413,8 @@ delta_match (void *cls,
413 GNUNET_HELLO_iterate_addresses (dc->old_hello, 413 GNUNET_HELLO_iterate_addresses (dc->old_hello,
414 GNUNET_NO, &get_match_exp, &ec); 414 GNUNET_NO, &get_match_exp, &ec);
415 if ((ec.found == GNUNET_YES) && 415 if ((ec.found == GNUNET_YES) &&
416 ((ec.expiration.value > expiration.value) || 416 ((ec.expiration.abs_value > expiration.abs_value) ||
417 (ec.expiration.value >= dc->expiration_limit.value))) 417 (ec.expiration.abs_value >= dc->expiration_limit.abs_value)))
418 return GNUNET_YES; /* skip */ 418 return GNUNET_YES; /* skip */
419 ret = dc->it (dc->it_cls, tname, expiration, addr, addrlen); 419 ret = dc->it (dc->it_cls, tname, expiration, addr, addrlen);
420 return ret; 420 return ret;
@@ -560,7 +560,7 @@ find_other_matching (void *cls,
560{ 560{
561 struct EqualsContext *ec = cls; 561 struct EqualsContext *ec = cls;
562 562
563 if (expiration.value < ec->expiration_limit.value) 563 if (expiration.abs_value < ec->expiration_limit.abs_value)
564 return GNUNET_YES; 564 return GNUNET_YES;
565 if ( (addrlen == ec->addrlen) && 565 if ( (addrlen == ec->addrlen) &&
566 (0 == strcmp (tname, 566 (0 == strcmp (tname,
@@ -570,7 +570,7 @@ find_other_matching (void *cls,
570 addrlen)) ) 570 addrlen)) )
571 { 571 {
572 ec->found = GNUNET_YES; 572 ec->found = GNUNET_YES;
573 if (expiration.value < ec->expiration.value) 573 if (expiration.abs_value < ec->expiration.abs_value)
574 ec->result = GNUNET_TIME_absolute_min (expiration, 574 ec->result = GNUNET_TIME_absolute_min (expiration,
575 ec->result); 575 ec->result);
576 return GNUNET_SYSERR; 576 return GNUNET_SYSERR;
@@ -587,7 +587,7 @@ find_matching (void *cls,
587{ 587{
588 struct EqualsContext *ec = cls; 588 struct EqualsContext *ec = cls;
589 589
590 if (expiration.value < ec->expiration_limit.value) 590 if (expiration.abs_value < ec->expiration_limit.abs_value)
591 return GNUNET_YES; 591 return GNUNET_YES;
592 ec->tname = tname; 592 ec->tname = tname;
593 ec->expiration = expiration; 593 ec->expiration = expiration;
@@ -642,8 +642,8 @@ GNUNET_HELLO_equals (const struct
642 GNUNET_NO, 642 GNUNET_NO,
643 &find_matching, 643 &find_matching,
644 &ec); 644 &ec);
645 if (ec.result.value == 645 if (ec.result.abs_value ==
646 GNUNET_TIME_UNIT_ZERO.value) 646 GNUNET_TIME_UNIT_ZERO.rel_value)
647 return ec.result; 647 return ec.result;
648 ec.h2 = h1; 648 ec.h2 = h1;
649 GNUNET_HELLO_iterate_addresses (h2, 649 GNUNET_HELLO_iterate_addresses (h2,
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c
index 61e79c6cf..a5d345b60 100644
--- a/src/hostlist/hostlist-client.c
+++ b/src/hostlist/hostlist-client.c
@@ -810,7 +810,7 @@ task_download (void *cls,
810 clean_up (); 810 clean_up ();
811 return; 811 return;
812 } 812 }
813 if (GNUNET_TIME_absolute_get_remaining (end_time).value == 0) 813 if (GNUNET_TIME_absolute_get_remaining (end_time).rel_value == 0)
814 { 814 {
815 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 815 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
816 _("Timeout trying to download hostlist from `%s'\n"), 816 _("Timeout trying to download hostlist from `%s'\n"),
@@ -1072,16 +1072,16 @@ task_check (void *cls,
1072 return; /* in shutdown */ 1072 return; /* in shutdown */
1073 } 1073 }
1074 delay = hostlist_delay; 1074 delay = hostlist_delay;
1075 if (hostlist_delay.value == 0) 1075 if (hostlist_delay.rel_value == 0)
1076 hostlist_delay = GNUNET_TIME_UNIT_SECONDS; 1076 hostlist_delay = GNUNET_TIME_UNIT_SECONDS;
1077 else 1077 else
1078 hostlist_delay = GNUNET_TIME_relative_multiply (hostlist_delay, 2); 1078 hostlist_delay = GNUNET_TIME_relative_multiply (hostlist_delay, 2);
1079 if (hostlist_delay.value > GNUNET_TIME_UNIT_HOURS.value * (1 + stat_connection_count)) 1079 if (hostlist_delay.rel_value > GNUNET_TIME_UNIT_HOURS.rel_value * (1 + stat_connection_count))
1080 hostlist_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 1080 hostlist_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS,
1081 (1 + stat_connection_count)); 1081 (1 + stat_connection_count));
1082 GNUNET_STATISTICS_set (stats, 1082 GNUNET_STATISTICS_set (stats,
1083 gettext_noop("# milliseconds between hostlist downloads"), 1083 gettext_noop("# milliseconds between hostlist downloads"),
1084 hostlist_delay.value, 1084 hostlist_delay.rel_value,
1085 GNUNET_YES); 1085 GNUNET_YES);
1086 if (0 == once) 1086 if (0 == once)
1087 { 1087 {
@@ -1092,7 +1092,7 @@ task_check (void *cls,
1092 _("Have %u/%u connections. Will consider downloading hostlist in %llums\n"), 1092 _("Have %u/%u connections. Will consider downloading hostlist in %llums\n"),
1093 stat_connection_count, 1093 stat_connection_count,
1094 MIN_CONNECTIONS, 1094 MIN_CONNECTIONS,
1095 (unsigned long long) delay.value); 1095 (unsigned long long) delay.rel_value);
1096 ti_check_download = GNUNET_SCHEDULER_add_delayed (sched, 1096 ti_check_download = GNUNET_SCHEDULER_add_delayed (sched,
1097 delay, 1097 delay,
1098 &task_check, 1098 &task_check,
@@ -1135,7 +1135,7 @@ task_hostlist_saving (void *cls,
1135 1135
1136 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1136 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1137 _("Hostlists will be saved to file again in %llums\n"), 1137 _("Hostlists will be saved to file again in %llums\n"),
1138 (unsigned long long) SAVING_INTERVALL.value); 1138 (unsigned long long) SAVING_INTERVALL.rel_value);
1139 ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched, 1139 ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched,
1140 SAVING_INTERVALL, 1140 SAVING_INTERVALL,
1141 &task_hostlist_saving, 1141 &task_hostlist_saving,
@@ -1271,7 +1271,7 @@ handler_advertisement (void *cls,
1271 1271
1272 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1272 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1273 "Testing new hostlist advertisements is locked for the next %u ms\n", 1273 "Testing new hostlist advertisements is locked for the next %u ms\n",
1274 TESTING_INTERVAL.value); 1274 TESTING_INTERVAL.rel_value);
1275 1275
1276 ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (sched, 1276 ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (sched,
1277 &task_download_dispatcher, 1277 &task_download_dispatcher,
@@ -1315,7 +1315,7 @@ process_stat (void *cls,
1315 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1315 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1316 _("Initial time between hostlist downloads is %llums\n"), 1316 _("Initial time between hostlist downloads is %llums\n"),
1317 (unsigned long long) value); 1317 (unsigned long long) value);
1318 hostlist_delay.value = value; 1318 hostlist_delay.rel_value = value;
1319 return GNUNET_OK; 1319 return GNUNET_OK;
1320} 1320}
1321 1321
@@ -1384,8 +1384,8 @@ load_hostlist_file ()
1384 hostlist->hostlist_uri = (const char *) &hostlist[1]; 1384 hostlist->hostlist_uri = (const char *) &hostlist[1];
1385 memcpy (&hostlist[1], uri, strlen(uri)+1); 1385 memcpy (&hostlist[1], uri, strlen(uri)+1);
1386 hostlist->quality = quality; 1386 hostlist->quality = quality;
1387 hostlist->time_creation.value = created; 1387 hostlist->time_creation.abs_value = created;
1388 hostlist->time_last_usage.value = last_used; 1388 hostlist->time_last_usage.abs_value = last_used;
1389 GNUNET_CONTAINER_DLL_insert(linked_list_head, linked_list_tail, hostlist); 1389 GNUNET_CONTAINER_DLL_insert(linked_list_head, linked_list_tail, hostlist);
1390 linked_list_size++; 1390 linked_list_size++;
1391 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1391 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1472,9 +1472,9 @@ static void save_hostlist_file ( int shutdown )
1472 (GNUNET_OK != 1472 (GNUNET_OK !=
1473 GNUNET_BIO_write_int64 (wh, pos->quality)) || 1473 GNUNET_BIO_write_int64 (wh, pos->quality)) ||
1474 (GNUNET_OK != 1474 (GNUNET_OK !=
1475 GNUNET_BIO_write_int64 (wh, pos->time_last_usage.value)) || 1475 GNUNET_BIO_write_int64 (wh, pos->time_last_usage.abs_value)) ||
1476 (GNUNET_OK != 1476 (GNUNET_OK !=
1477 GNUNET_BIO_write_int64 (wh, pos->time_creation.value)) || 1477 GNUNET_BIO_write_int64 (wh, pos->time_creation.abs_value)) ||
1478 (GNUNET_OK != 1478 (GNUNET_OK !=
1479 GNUNET_BIO_write_int32 (wh, pos->hello_count))) 1479 GNUNET_BIO_write_int32 (wh, pos->hello_count)))
1480 { 1480 {
@@ -1554,7 +1554,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
1554 load_hostlist_file (); 1554 load_hostlist_file ();
1555 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1555 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1556 _("Hostlists will be saved to file again in %llums\n"), 1556 _("Hostlists will be saved to file again in %llums\n"),
1557 (unsigned long long) SAVING_INTERVALL.value); 1557 (unsigned long long) SAVING_INTERVALL.rel_value);
1558 ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched, 1558 ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched,
1559 SAVING_INTERVALL, 1559 SAVING_INTERVALL,
1560 &task_hostlist_saving, 1560 &task_hostlist_saving,
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c
index d8c8db476..8fdee5545 100644
--- a/src/hostlist/hostlist-server.c
+++ b/src/hostlist/hostlist-server.c
@@ -163,7 +163,7 @@ check_has_addr (void *cls,
163{ 163{
164 int *arg = cls; 164 int *arg = cls;
165 165
166 if (GNUNET_TIME_absolute_get_remaining (expiration).value == 0) 166 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0)
167 { 167 {
168 GNUNET_STATISTICS_update (stats, 168 GNUNET_STATISTICS_update (stats,
169 gettext_noop("expired addresses encountered"), 169 gettext_noop("expired addresses encountered"),
@@ -533,7 +533,7 @@ prepare_daemon (struct MHD_Daemon *daemon_handle)
533 &max)); 533 &max));
534 haveto = MHD_get_timeout (daemon_handle, &timeout); 534 haveto = MHD_get_timeout (daemon_handle, &timeout);
535 if (haveto == MHD_YES) 535 if (haveto == MHD_YES)
536 tv.value = (uint64_t) timeout; 536 tv.rel_value = (uint64_t) timeout;
537 else 537 else
538 tv = GNUNET_TIME_UNIT_FOREVER_REL; 538 tv = GNUNET_TIME_UNIT_FOREVER_REL;
539 GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1); 539 GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1);