diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-10-27 09:35:32 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-10-27 09:35:32 +0000 |
commit | 06076559b84c1053d82929c05620ab0bd60b9c5f (patch) | |
tree | 872b96d70ebc8437c4663c7ff0563ece17c90757 /src | |
parent | c279ce86d89efd55f9b9019690aa0a15d89ccfc7 (diff) | |
download | gnunet-06076559b84c1053d82929c05620ab0bd60b9c5f.tar.gz gnunet-06076559b84c1053d82929c05620ab0bd60b9c5f.zip |
Refactoring gnunet_time
Diffstat (limited to 'src')
-rw-r--r-- | src/core/core_api.c | 6 | ||||
-rw-r--r-- | src/core/gnunet-service-core.c | 47 | ||||
-rw-r--r-- | src/core/test_core_api_reliability.c | 2 |
3 files changed, 27 insertions, 28 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c index 0f84771b0..dd8919ea1 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -662,12 +662,12 @@ transmit_start (void *cls, size_t size, void *buf) | |||
662 | if (size == 0) | 662 | if (size == 0) |
663 | { | 663 | { |
664 | if ((h->init == NULL) || | 664 | if ((h->init == NULL) || |
665 | (GNUNET_TIME_absolute_get ().value < h->startup_timeout.value)) | 665 | (GNUNET_TIME_absolute_get ().abs_value < h->startup_timeout.abs_value)) |
666 | { | 666 | { |
667 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 667 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
668 | _("Failed to connect to core service, retrying.\n")); | 668 | _("Failed to connect to core service, retrying.\n")); |
669 | delay = GNUNET_TIME_absolute_get_remaining (h->startup_timeout); | 669 | delay = GNUNET_TIME_absolute_get_remaining (h->startup_timeout); |
670 | if ((h->init == NULL) || (delay.value > 1000)) | 670 | if ((h->init == NULL) || (delay.rel_value > 1000)) |
671 | delay = GNUNET_TIME_UNIT_SECONDS; | 671 | delay = GNUNET_TIME_UNIT_SECONDS; |
672 | if (h->init == NULL) | 672 | if (h->init == NULL) |
673 | h->startup_timeout = | 673 | h->startup_timeout = |
@@ -794,7 +794,7 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
794 | #if DEBUG_CORE | 794 | #if DEBUG_CORE |
795 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 795 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
796 | "Trying to connect to core service in next %llu ms.\n", | 796 | "Trying to connect to core service in next %llu ms.\n", |
797 | timeout.value); | 797 | timeout.rel_value); |
798 | #endif | 798 | #endif |
799 | h->cth = | 799 | h->cth = |
800 | GNUNET_CLIENT_notify_transmit_ready (h->client_notifications, | 800 | GNUNET_CLIENT_notify_transmit_ready (h->client_notifications, |
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index c0213f337..16200c822 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -1171,7 +1171,7 @@ handle_client_request_info (void *cls, | |||
1171 | else if (want_reserv > 0) | 1171 | else if (want_reserv > 0) |
1172 | { | 1172 | { |
1173 | if (GNUNET_BANDWIDTH_tracker_get_delay (&n->available_recv_window, | 1173 | if (GNUNET_BANDWIDTH_tracker_get_delay (&n->available_recv_window, |
1174 | want_reserv).value == 0) | 1174 | want_reserv).rel_value == 0) |
1175 | got_reserv = want_reserv; | 1175 | got_reserv = want_reserv; |
1176 | else | 1176 | else |
1177 | got_reserv = 0; /* all or nothing */ | 1177 | got_reserv = 0; /* all or nothing */ |
@@ -1442,7 +1442,7 @@ consider_free_neighbour (struct Neighbour *n) | |||
1442 | 1442 | ||
1443 | left = GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (n->last_activity, | 1443 | left = GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (n->last_activity, |
1444 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); | 1444 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); |
1445 | if (left.value > 0) | 1445 | if (left.rel_value > 0) |
1446 | { | 1446 | { |
1447 | if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) | 1447 | if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) |
1448 | GNUNET_SCHEDULER_cancel (sched, n->dead_clean_task); | 1448 | GNUNET_SCHEDULER_cancel (sched, n->dead_clean_task); |
@@ -1574,8 +1574,7 @@ process_encrypted_neighbour_queue (struct Neighbour *n) | |||
1574 | "Asking transport for transmission of %u bytes to `%4s' in next %llu ms\n", | 1574 | "Asking transport for transmission of %u bytes to `%4s' in next %llu ms\n", |
1575 | (unsigned int) m->size, | 1575 | (unsigned int) m->size, |
1576 | GNUNET_i2s (&n->peer), | 1576 | GNUNET_i2s (&n->peer), |
1577 | (unsigned long long) GNUNET_TIME_absolute_get_remaining (m->deadline). | 1577 | (unsigned long long) GNUNET_TIME_absolute_get_remaining (m->deadline).rel_value); |
1578 | value); | ||
1579 | #endif | 1578 | #endif |
1580 | n->th = | 1579 | n->th = |
1581 | GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, | 1580 | GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, |
@@ -1731,7 +1730,7 @@ select_messages (struct Neighbour *n, | |||
1731 | if (discard_low_prio == GNUNET_NO) | 1730 | if (discard_low_prio == GNUNET_NO) |
1732 | { | 1731 | { |
1733 | delta = GNUNET_TIME_absolute_get_difference (t, pos->deadline); | 1732 | delta = GNUNET_TIME_absolute_get_difference (t, pos->deadline); |
1734 | if (delta.value > 0) | 1733 | if (delta.rel_value > 0) |
1735 | { | 1734 | { |
1736 | // FIXME: HUH? Check! | 1735 | // FIXME: HUH? Check! |
1737 | t = pos->deadline; | 1736 | t = pos->deadline; |
@@ -1752,7 +1751,7 @@ select_messages (struct Neighbour *n, | |||
1752 | slack = GNUNET_TIME_relative_min (slack, | 1751 | slack = GNUNET_TIME_relative_min (slack, |
1753 | GNUNET_BANDWIDTH_value_get_delay_for (n->bw_out, | 1752 | GNUNET_BANDWIDTH_value_get_delay_for (n->bw_out, |
1754 | avail)); | 1753 | avail)); |
1755 | if (pos->deadline.value <= now.value) | 1754 | if (pos->deadline.abs_value <= now.abs_value) |
1756 | { | 1755 | { |
1757 | /* now or never */ | 1756 | /* now or never */ |
1758 | slack = GNUNET_TIME_UNIT_ZERO; | 1757 | slack = GNUNET_TIME_UNIT_ZERO; |
@@ -1794,7 +1793,7 @@ select_messages (struct Neighbour *n, | |||
1794 | } | 1793 | } |
1795 | /* guard against sending "tiny" messages with large headers without | 1794 | /* guard against sending "tiny" messages with large headers without |
1796 | urgent deadlines */ | 1795 | urgent deadlines */ |
1797 | if ( (slack.value > GNUNET_CONSTANTS_MAX_CORK_DELAY.value) && | 1796 | if ( (slack.rel_value > GNUNET_CONSTANTS_MAX_CORK_DELAY.rel_value) && |
1798 | (size > 4 * off) && | 1797 | (size > 4 * off) && |
1799 | (queue_size <= MAX_PEER_QUEUE_SIZE - 2) ) | 1798 | (queue_size <= MAX_PEER_QUEUE_SIZE - 2) ) |
1800 | { | 1799 | { |
@@ -1815,7 +1814,7 @@ select_messages (struct Neighbour *n, | |||
1815 | #if DEBUG_CORE | 1814 | #if DEBUG_CORE |
1816 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1815 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1817 | "Deferring transmission for %llums due to underfull message buffer size (%u/%u)\n", | 1816 | "Deferring transmission for %llums due to underfull message buffer size (%u/%u)\n", |
1818 | (unsigned long long) retry_time->value, | 1817 | (unsigned long long) retry_time->rel_value, |
1819 | (unsigned int) off, | 1818 | (unsigned int) off, |
1820 | (unsigned int) size); | 1819 | (unsigned int) size); |
1821 | #endif | 1820 | #endif |
@@ -1896,7 +1895,7 @@ batch_message (struct Neighbour *n, | |||
1896 | #if DEBUG_CORE | 1895 | #if DEBUG_CORE |
1897 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1896 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1898 | "No messages selected, will try again in %llu ms\n", | 1897 | "No messages selected, will try again in %llu ms\n", |
1899 | retry_time->value); | 1898 | retry_time->rel_value); |
1900 | #endif | 1899 | #endif |
1901 | return 0; | 1900 | return 0; |
1902 | } | 1901 | } |
@@ -1954,9 +1953,9 @@ batch_message (struct Neighbour *n, | |||
1954 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1953 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1955 | "Adding plaintext message of size %u with deadline %llu ms to batch\n", | 1954 | "Adding plaintext message of size %u with deadline %llu ms to batch\n", |
1956 | (unsigned int) pos->size, | 1955 | (unsigned int) pos->size, |
1957 | (unsigned long long) GNUNET_TIME_absolute_get_remaining (pos->deadline).value); | 1956 | (unsigned long long) GNUNET_TIME_absolute_get_remaining (pos->deadline).rel_value); |
1958 | #endif | 1957 | #endif |
1959 | deadline->value = GNUNET_MIN (deadline->value, pos->deadline.value); | 1958 | deadline->abs_value = GNUNET_MIN (deadline->abs_value, pos->deadline.abs_value); |
1960 | GNUNET_free (pos); | 1959 | GNUNET_free (pos); |
1961 | if (prev == NULL) | 1960 | if (prev == NULL) |
1962 | n->messages = next; | 1961 | n->messages = next; |
@@ -1972,7 +1971,7 @@ batch_message (struct Neighbour *n, | |||
1972 | #if DEBUG_CORE | 1971 | #if DEBUG_CORE |
1973 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1972 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1974 | "Deadline for message batch is %llu ms\n", | 1973 | "Deadline for message batch is %llu ms\n", |
1975 | GNUNET_TIME_absolute_get_remaining (*deadline).value); | 1974 | GNUNET_TIME_absolute_get_remaining (*deadline).rel_value); |
1976 | #endif | 1975 | #endif |
1977 | return ret; | 1976 | return ret; |
1978 | } | 1977 | } |
@@ -2000,12 +1999,12 @@ discard_expired_messages (struct Neighbour *n) | |||
2000 | { | 1999 | { |
2001 | next = pos->next; | 2000 | next = pos->next; |
2002 | delta = GNUNET_TIME_absolute_get_difference (pos->deadline, now); | 2001 | delta = GNUNET_TIME_absolute_get_difference (pos->deadline, now); |
2003 | if (delta.value > PAST_EXPIRATION_DISCARD_TIME.value) | 2002 | if (delta.rel_value > PAST_EXPIRATION_DISCARD_TIME.rel_value) |
2004 | { | 2003 | { |
2005 | #if DEBUG_CORE | 2004 | #if DEBUG_CORE |
2006 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 2005 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2007 | "Message is %llu ms past due, discarding.\n", | 2006 | "Message is %llu ms past due, discarding.\n", |
2008 | delta.value); | 2007 | delta.rel_value); |
2009 | #endif | 2008 | #endif |
2010 | if (prev == NULL) | 2009 | if (prev == NULL) |
2011 | n->messages = next; | 2010 | n->messages = next; |
@@ -2198,7 +2197,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n) | |||
2198 | "Encrypting %u bytes of plaintext messages for `%4s' for transmission in %llums.\n", | 2197 | "Encrypting %u bytes of plaintext messages for `%4s' for transmission in %llums.\n", |
2199 | (unsigned int) used - ENCRYPTED_HEADER_SIZE, | 2198 | (unsigned int) used - ENCRYPTED_HEADER_SIZE, |
2200 | GNUNET_i2s(&n->peer), | 2199 | GNUNET_i2s(&n->peer), |
2201 | (unsigned long long) GNUNET_TIME_absolute_get_remaining (deadline).value); | 2200 | (unsigned long long) GNUNET_TIME_absolute_get_remaining (deadline).abs_value); |
2202 | #endif | 2201 | #endif |
2203 | GNUNET_assert (GNUNET_OK == | 2202 | GNUNET_assert (GNUNET_OK == |
2204 | do_encrypt (n, | 2203 | do_encrypt (n, |
@@ -2419,7 +2418,7 @@ handle_client_send (void *cls, | |||
2419 | /* insert, keep list sorted by deadline */ | 2418 | /* insert, keep list sorted by deadline */ |
2420 | prev = NULL; | 2419 | prev = NULL; |
2421 | pos = n->messages; | 2420 | pos = n->messages; |
2422 | while ((pos != NULL) && (pos->deadline.value < e->deadline.value)) | 2421 | while ((pos != NULL) && (pos->deadline.abs_value < e->deadline.abs_value)) |
2423 | { | 2422 | { |
2424 | prev = pos; | 2423 | prev = pos; |
2425 | pos = pos->next; | 2424 | pos = pos->next; |
@@ -2818,7 +2817,7 @@ send_key (struct Neighbour *n) | |||
2818 | #if DEBUG_CORE | 2817 | #if DEBUG_CORE |
2819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2818 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2820 | "Have %llu ms left for `%s' transmission.\n", | 2819 | "Have %llu ms left for `%s' transmission.\n", |
2821 | (unsigned long long) GNUNET_TIME_absolute_get_remaining (me->deadline).value, | 2820 | (unsigned long long) GNUNET_TIME_absolute_get_remaining (me->deadline).rel_value, |
2822 | "SET_KEY"); | 2821 | "SET_KEY"); |
2823 | #endif | 2822 | #endif |
2824 | trigger_processing: | 2823 | trigger_processing: |
@@ -3201,7 +3200,7 @@ handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m) | |||
3201 | t = GNUNET_TIME_absolute_ntoh (m->creation_time); | 3200 | t = GNUNET_TIME_absolute_ntoh (m->creation_time); |
3202 | if (((n->status == PEER_STATE_KEY_RECEIVED) || | 3201 | if (((n->status == PEER_STATE_KEY_RECEIVED) || |
3203 | (n->status == PEER_STATE_KEY_CONFIRMED)) && | 3202 | (n->status == PEER_STATE_KEY_CONFIRMED)) && |
3204 | (t.value < n->decrypt_key_created.value)) | 3203 | (t.abs_value < n->decrypt_key_created.abs_value)) |
3205 | { | 3204 | { |
3206 | /* this could rarely happen due to massive re-ordering of | 3205 | /* this could rarely happen due to massive re-ordering of |
3207 | messages on the network level, but is most likely either | 3206 | messages on the network level, but is most likely either |
@@ -3229,7 +3228,7 @@ handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m) | |||
3229 | 1, | 3228 | 1, |
3230 | GNUNET_NO); | 3229 | GNUNET_NO); |
3231 | n->decrypt_key = k; | 3230 | n->decrypt_key = k; |
3232 | if (n->decrypt_key_created.value != t.value) | 3231 | if (n->decrypt_key_created.abs_value != t.abs_value) |
3233 | { | 3232 | { |
3234 | /* fresh key, reset sequence numbers */ | 3233 | /* fresh key, reset sequence numbers */ |
3235 | n->last_sequence_number_received = 0; | 3234 | n->last_sequence_number_received = 0; |
@@ -3518,12 +3517,12 @@ handle_encrypted_message (struct Neighbour *n, | |||
3518 | 3517 | ||
3519 | /* check timestamp */ | 3518 | /* check timestamp */ |
3520 | t = GNUNET_TIME_absolute_ntoh (pt->timestamp); | 3519 | t = GNUNET_TIME_absolute_ntoh (pt->timestamp); |
3521 | if (GNUNET_TIME_absolute_get_duration (t).value > MAX_MESSAGE_AGE.value) | 3520 | if (GNUNET_TIME_absolute_get_duration (t).rel_value > MAX_MESSAGE_AGE.rel_value) |
3522 | { | 3521 | { |
3523 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 3522 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3524 | _ | 3523 | _ |
3525 | ("Message received far too old (%llu ms). Content ignored.\n"), | 3524 | ("Message received far too old (%llu ms). Content ignored.\n"), |
3526 | GNUNET_TIME_absolute_get_duration (t).value); | 3525 | GNUNET_TIME_absolute_get_duration (t).rel_value); |
3527 | GNUNET_STATISTICS_set (stats, | 3526 | GNUNET_STATISTICS_set (stats, |
3528 | gettext_noop ("# bytes dropped (ancient message)"), | 3527 | gettext_noop ("# bytes dropped (ancient message)"), |
3529 | size, | 3528 | size, |
@@ -3612,7 +3611,7 @@ handle_transport_receive (void *cls, | |||
3612 | n = find_neighbour (peer); | 3611 | n = find_neighbour (peer); |
3613 | if (n == NULL) | 3612 | if (n == NULL) |
3614 | n = create_neighbour (peer); | 3613 | n = create_neighbour (peer); |
3615 | changed = (latency.value != n->last_latency.value) || (distance != n->last_distance); | 3614 | changed = (latency.rel_value != n->last_latency.rel_value) || (distance != n->last_distance); |
3616 | n->last_latency = latency; | 3615 | n->last_latency = latency; |
3617 | n->last_distance = distance; | 3616 | n->last_distance = distance; |
3618 | up = (n->status == PEER_STATE_KEY_CONFIRMED); | 3617 | up = (n->status == PEER_STATE_KEY_CONFIRMED); |
@@ -3766,8 +3765,8 @@ neighbour_quota_update (void *cls, | |||
3766 | else | 3765 | else |
3767 | q_in = GNUNET_BANDWIDTH_value_init (need_per_peer + (uint32_t) share); | 3766 | q_in = GNUNET_BANDWIDTH_value_init (need_per_peer + (uint32_t) share); |
3768 | /* check if we want to disconnect for good due to inactivity */ | 3767 | /* check if we want to disconnect for good due to inactivity */ |
3769 | if ( (GNUNET_TIME_absolute_get_duration (n->last_activity).value > GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.value) && | 3768 | if ( (GNUNET_TIME_absolute_get_duration (n->last_activity).rel_value > GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value) && |
3770 | (GNUNET_TIME_absolute_get_duration (n->time_established).value > GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.value) ) | 3769 | (GNUNET_TIME_absolute_get_duration (n->time_established).rel_value > GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value) ) |
3771 | { | 3770 | { |
3772 | #if DEBUG_CORE | 3771 | #if DEBUG_CORE |
3773 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3772 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index f981f105a..b25cb89f2 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c | |||
@@ -123,7 +123,7 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
123 | p1.th = NULL; | 123 | p1.th = NULL; |
124 | GNUNET_TRANSPORT_disconnect (p2.th); | 124 | GNUNET_TRANSPORT_disconnect (p2.th); |
125 | p2.th = NULL; | 125 | p2.th = NULL; |
126 | delta = GNUNET_TIME_absolute_get_duration (start_time).value; | 126 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; |
127 | fprintf (stderr, | 127 | fprintf (stderr, |
128 | "\nThroughput was %llu kb/s\n", | 128 | "\nThroughput was %llu kb/s\n", |
129 | total_bytes * 1000 / 1024 / delta); | 129 | total_bytes * 1000 / 1024 / delta); |