From ba9ef31948175e08469403cfd8840db7efe5886f Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Wed, 27 Oct 2010 09:48:46 +0000 Subject: Refactoring gnunet time --- src/hello/hello.c | 18 +++++++++--------- src/hostlist/hostlist-client.c | 26 +++++++++++++------------- src/hostlist/hostlist-server.c | 4 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src') 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, ec.tname = tname; GNUNET_HELLO_iterate_addresses (mc->other, GNUNET_NO, &get_match_exp, &ec); if ( (ec.found == GNUNET_NO) || - (ec.expiration.value < expiration.value) || - ( (ec.expiration.value == expiration.value) && + (ec.expiration.abs_value < expiration.abs_value) || + ( (ec.expiration.abs_value == expiration.abs_value) && (mc->take_equal == GNUNET_YES) ) ) { mc->ret += GNUNET_HELLO_add_address (tname, @@ -413,8 +413,8 @@ delta_match (void *cls, GNUNET_HELLO_iterate_addresses (dc->old_hello, GNUNET_NO, &get_match_exp, &ec); if ((ec.found == GNUNET_YES) && - ((ec.expiration.value > expiration.value) || - (ec.expiration.value >= dc->expiration_limit.value))) + ((ec.expiration.abs_value > expiration.abs_value) || + (ec.expiration.abs_value >= dc->expiration_limit.abs_value))) return GNUNET_YES; /* skip */ ret = dc->it (dc->it_cls, tname, expiration, addr, addrlen); return ret; @@ -560,7 +560,7 @@ find_other_matching (void *cls, { struct EqualsContext *ec = cls; - if (expiration.value < ec->expiration_limit.value) + if (expiration.abs_value < ec->expiration_limit.abs_value) return GNUNET_YES; if ( (addrlen == ec->addrlen) && (0 == strcmp (tname, @@ -570,7 +570,7 @@ find_other_matching (void *cls, addrlen)) ) { ec->found = GNUNET_YES; - if (expiration.value < ec->expiration.value) + if (expiration.abs_value < ec->expiration.abs_value) ec->result = GNUNET_TIME_absolute_min (expiration, ec->result); return GNUNET_SYSERR; @@ -587,7 +587,7 @@ find_matching (void *cls, { struct EqualsContext *ec = cls; - if (expiration.value < ec->expiration_limit.value) + if (expiration.abs_value < ec->expiration_limit.abs_value) return GNUNET_YES; ec->tname = tname; ec->expiration = expiration; @@ -642,8 +642,8 @@ GNUNET_HELLO_equals (const struct GNUNET_NO, &find_matching, &ec); - if (ec.result.value == - GNUNET_TIME_UNIT_ZERO.value) + if (ec.result.abs_value == + GNUNET_TIME_UNIT_ZERO.rel_value) return ec.result; ec.h2 = h1; 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, clean_up (); return; } - if (GNUNET_TIME_absolute_get_remaining (end_time).value == 0) + if (GNUNET_TIME_absolute_get_remaining (end_time).rel_value == 0) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Timeout trying to download hostlist from `%s'\n"), @@ -1072,16 +1072,16 @@ task_check (void *cls, return; /* in shutdown */ } delay = hostlist_delay; - if (hostlist_delay.value == 0) + if (hostlist_delay.rel_value == 0) hostlist_delay = GNUNET_TIME_UNIT_SECONDS; else hostlist_delay = GNUNET_TIME_relative_multiply (hostlist_delay, 2); - if (hostlist_delay.value > GNUNET_TIME_UNIT_HOURS.value * (1 + stat_connection_count)) + if (hostlist_delay.rel_value > GNUNET_TIME_UNIT_HOURS.rel_value * (1 + stat_connection_count)) hostlist_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, (1 + stat_connection_count)); GNUNET_STATISTICS_set (stats, gettext_noop("# milliseconds between hostlist downloads"), - hostlist_delay.value, + hostlist_delay.rel_value, GNUNET_YES); if (0 == once) { @@ -1092,7 +1092,7 @@ task_check (void *cls, _("Have %u/%u connections. Will consider downloading hostlist in %llums\n"), stat_connection_count, MIN_CONNECTIONS, - (unsigned long long) delay.value); + (unsigned long long) delay.rel_value); ti_check_download = GNUNET_SCHEDULER_add_delayed (sched, delay, &task_check, @@ -1135,7 +1135,7 @@ task_hostlist_saving (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Hostlists will be saved to file again in %llums\n"), - (unsigned long long) SAVING_INTERVALL.value); + (unsigned long long) SAVING_INTERVALL.rel_value); ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched, SAVING_INTERVALL, &task_hostlist_saving, @@ -1271,7 +1271,7 @@ handler_advertisement (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing new hostlist advertisements is locked for the next %u ms\n", - TESTING_INTERVAL.value); + TESTING_INTERVAL.rel_value); ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (sched, &task_download_dispatcher, @@ -1315,7 +1315,7 @@ process_stat (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Initial time between hostlist downloads is %llums\n"), (unsigned long long) value); - hostlist_delay.value = value; + hostlist_delay.rel_value = value; return GNUNET_OK; } @@ -1384,8 +1384,8 @@ load_hostlist_file () hostlist->hostlist_uri = (const char *) &hostlist[1]; memcpy (&hostlist[1], uri, strlen(uri)+1); hostlist->quality = quality; - hostlist->time_creation.value = created; - hostlist->time_last_usage.value = last_used; + hostlist->time_creation.abs_value = created; + hostlist->time_last_usage.abs_value = last_used; GNUNET_CONTAINER_DLL_insert(linked_list_head, linked_list_tail, hostlist); linked_list_size++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1472,9 +1472,9 @@ static void save_hostlist_file ( int shutdown ) (GNUNET_OK != GNUNET_BIO_write_int64 (wh, pos->quality)) || (GNUNET_OK != - GNUNET_BIO_write_int64 (wh, pos->time_last_usage.value)) || + GNUNET_BIO_write_int64 (wh, pos->time_last_usage.abs_value)) || (GNUNET_OK != - GNUNET_BIO_write_int64 (wh, pos->time_creation.value)) || + GNUNET_BIO_write_int64 (wh, pos->time_creation.abs_value)) || (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pos->hello_count))) { @@ -1554,7 +1554,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, load_hostlist_file (); GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Hostlists will be saved to file again in %llums\n"), - (unsigned long long) SAVING_INTERVALL.value); + (unsigned long long) SAVING_INTERVALL.rel_value); ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched, SAVING_INTERVALL, &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, { int *arg = cls; - if (GNUNET_TIME_absolute_get_remaining (expiration).value == 0) + if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) { GNUNET_STATISTICS_update (stats, gettext_noop("expired addresses encountered"), @@ -533,7 +533,7 @@ prepare_daemon (struct MHD_Daemon *daemon_handle) &max)); haveto = MHD_get_timeout (daemon_handle, &timeout); if (haveto == MHD_YES) - tv.value = (uint64_t) timeout; + tv.rel_value = (uint64_t) timeout; else tv = GNUNET_TIME_UNIT_FOREVER_REL; GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1); -- cgit v1.2.3