diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-11 21:21:56 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-11 21:21:56 +0000 |
commit | 3d7fefedc9ba60bd8e8448efe8b628446d958536 (patch) | |
tree | 61ce41a52cd6e7232cead77818ef265993b2427e /src/transport | |
parent | 4a0398474db197abed243a123fb971fbeeffab4b (diff) |
changing time measurement from milliseconds to microseconds
Diffstat (limited to 'src/transport')
22 files changed, 336 insertions, 258 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index f9585e512..2d939af36 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -286,8 +286,9 @@ GST_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, } end: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Allowing receive from peer %s to continue in %llu ms\n", - GNUNET_i2s (peer), (unsigned long long) ret.rel_value); + "Allowing receive from peer %s to continue in %s\n", + GNUNET_i2s (peer), + GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES)); return ret; } diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c index 4a9414622..0ca732d62 100644 --- a/src/transport/gnunet-service-transport_manipulation.c +++ b/src/transport/gnunet-service-transport_manipulation.c @@ -419,7 +419,7 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg if (UINT32_MAX != find_metric(tmp, GNUNET_ATS_QUALITY_NET_DELAY, TM_SEND)) { /* We have a delay */ - delay.rel_value = find_metric(tmp, GNUNET_ATS_QUALITY_NET_DELAY, TM_SEND); + delay.rel_value_us = find_metric (tmp, GNUNET_ATS_QUALITY_NET_DELAY, TM_SEND); dqe = GNUNET_malloc (sizeof (struct DelayQueueEntry) + msg_size); dqe->id = *target; dqe->tmp = tmp; @@ -434,8 +434,9 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg if (GNUNET_SCHEDULER_NO_TASK == tmp->send_delay_task) tmp->send_delay_task =GNUNET_SCHEDULER_add_delayed (delay, &send_delayed, dqe); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Delaying %u byte message to peer `%s' with generic delay for %llu ms\n", - msg_size, GNUNET_i2s (target), (long long unsigned int) delay.rel_value); + "Delaying %u byte message to peer `%s' with generic delay for %ms\n", + msg_size, GNUNET_i2s (target), + GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); return; } } @@ -443,7 +444,7 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg { GNUNET_break (GNUNET_YES == GST_neighbours_test_connected(target)); /* We have a delay */ - delay.rel_value = find_metric (&man_handle.general, GNUNET_ATS_QUALITY_NET_DELAY, TM_SEND); + delay.rel_value_us = find_metric (&man_handle.general, GNUNET_ATS_QUALITY_NET_DELAY, TM_SEND); dqe = GNUNET_malloc (sizeof (struct DelayQueueEntry) + msg_size); dqe->id = *target; dqe->tmp = NULL; @@ -460,8 +461,9 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg generic_send_delay_task = GNUNET_SCHEDULER_add_delayed (delay, &send_delayed, dqe); } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Delaying %u byte message to peer `%s' with peer specific delay for %llu ms\n", - msg_size, GNUNET_i2s (target), (long long unsigned int) delay.rel_value); + "Delaying %u byte message to peer `%s' with peer specific delay for %s\n", + msg_size, GNUNET_i2s (target), + GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); return; } @@ -540,28 +542,29 @@ GST_manipulation_recv (void *cls, struct GNUNET_TIME_Relative m_delay; g_recv_delay = find_metric (&man_handle.general, GNUNET_ATS_QUALITY_NET_DELAY, TM_RECEIVE); - if ((g_recv_delay >= GNUNET_TIME_UNIT_ZERO.rel_value) && (UINT32_MAX != g_recv_delay)) - m_delay.rel_value = g_recv_delay; /* Global delay */ + if ((g_recv_delay >= GNUNET_TIME_UNIT_ZERO.rel_value_us) && (UINT32_MAX != g_recv_delay)) + m_delay.rel_value_us = g_recv_delay; /* Global delay */ else - m_delay = GNUNET_TIME_UNIT_ZERO; + m_delay = GNUNET_TIME_UNIT_ZERO; if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (man_handle.peers, &peer->hashPubKey))) { - /* Manipulate receive delay */ - p_recv_delay = find_metric (tmp, GNUNET_ATS_QUALITY_NET_DELAY, TM_RECEIVE); - if (UINT32_MAX != p_recv_delay) - m_delay.rel_value = p_recv_delay; /* Peer specific delay */ + /* Manipulate receive delay */ + p_recv_delay = find_metric (tmp, GNUNET_ATS_QUALITY_NET_DELAY, TM_RECEIVE); + if (UINT32_MAX != p_recv_delay) + m_delay.rel_value_us = p_recv_delay; /* Peer specific delay */ } quota_delay = GST_receive_callback (cls, peer, message, session, sender_address, sender_address_len); - if (quota_delay.rel_value > m_delay.rel_value) + if (quota_delay.rel_value_us > m_delay.rel_value_us) m_delay = quota_delay; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Delaying next receive for peer `%s' for %llu ms\n", - GNUNET_i2s (peer), (long long unsigned int) m_delay.rel_value); + "Delaying next receive for peer `%s' for %s\n", + GNUNET_i2s (peer), + GNUNET_STRINGS_relative_time_to_string (m_delay, GNUNET_YES)); return m_delay; } diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 8f53b93be..f09641506 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2010,2011,2012 Christian Grothoff (and other contributing authors) + (C) 2010-2013 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -155,7 +155,7 @@ print_allocators () next = GNUNET_TIME_UNIT_ZERO_ABS; start = GNUNET_NO; } - if (0 == (rem = GNUNET_TIME_absolute_get_remaining(next)).rel_value) + if (0 == (rem = GNUNET_TIME_absolute_get_remaining(next)).rel_value_us) { fprintf (stderr, "Allocated in `%s' total: %5u bytes\n", __FILE__, bytes_alloced); while (NULL != cur) @@ -1406,7 +1406,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) while (NULL != (mq = n->messages_head)) { timeout = GNUNET_TIME_absolute_get_remaining (mq->timeout); - if (timeout.rel_value > 0) + if (timeout.rel_value_us > 0) break; GNUNET_STATISTICS_update (GST_stats, gettext_noop @@ -1443,7 +1443,7 @@ send_keepalive (struct NeighbourMapEntry *n) GNUNET_assert ((S_CONNECTED == n->state) || (S_CONNECTED_SWITCHING_BLACKLIST == n->state) || (S_CONNECTED_SWITCHING_CONNECT_SENT)); - if (GNUNET_TIME_absolute_get_remaining (n->keep_alive_time).rel_value > 0) + if (GNUNET_TIME_absolute_get_remaining (n->keep_alive_time).rel_value_us > 0) return; /* no keepalive needed at this time */ m.size = htons (sizeof (struct GNUNET_MessageHeader)); m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE); @@ -1534,14 +1534,16 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour) n->latency = GNUNET_TIME_absolute_get_duration (n->last_keep_alive_time); n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Latency for peer `%s' is %llu ms\n", - GNUNET_i2s (&n->id), n->latency.rel_value); + "Latency for peer `%s' is %s\n", + GNUNET_i2s (&n->id), + GNUNET_STRINGS_relative_time_to_string (n->latency, + GNUNET_YES)); /* append latency */ ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); - if (n->latency.rel_value > UINT32_MAX) + if (n->latency.rel_value_us > UINT32_MAX) latency = UINT32_MAX; else - latency = n->latency.rel_value; + latency = n->latency.rel_value_us; ats.value = htonl (latency); GST_ats_update_metrics (&n->id, n->primary_address.address, @@ -1622,17 +1624,18 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity } *do_forward = GNUNET_YES; ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 32 * 1024); - if (ret.rel_value > 0) + if (ret.rel_value_us > 0) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Throttling read (%llu bytes excess at %u b/s), waiting %llu ms before reading more.\n", + "Throttling read (%llu bytes excess at %u b/s), waiting %s before reading more.\n", (unsigned long long) n->in_tracker. consumption_since_last_update__, (unsigned int) n->in_tracker.available_bytes_per_s__, - (unsigned long long) ret.rel_value); + GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES)); GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# ms throttling suggested"), - (int64_t) ret.rel_value, GNUNET_NO); + (int64_t) ret.rel_value_us / 1000LL, + GNUNET_NO); } return ret; } @@ -2526,10 +2529,11 @@ master_task (void *cls, n->task = GNUNET_SCHEDULER_NO_TASK; delay = GNUNET_TIME_absolute_get_remaining (n->timeout); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Master task runs for neighbour `%s' in state %s with timeout in %llu ms\n", + "Master task runs for neighbour `%s' in state %s with timeout in %s\n", GNUNET_i2s (&n->id), print_state(n->state), - (unsigned long long) delay.rel_value); + GNUNET_STRINGS_relative_time_to_string (delay, + GNUNET_YES)); switch (n->state) { case S_NOT_CONNECTED: @@ -2539,7 +2543,7 @@ master_task (void *cls, free_neighbour (n, GNUNET_NO); return; case S_INIT_ATS: - if (0 == delay.rel_value) + if (0 == delay.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' timed out waiting for ATS to provide address\n", @@ -2550,7 +2554,7 @@ master_task (void *cls, } break; case S_INIT_BLACKLIST: - if (0 == delay.rel_value) + if (0 == delay.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' timed out waiting for BLACKLIST to approve address\n", @@ -2561,7 +2565,7 @@ master_task (void *cls, } break; case S_CONNECT_SENT: - if (0 == delay.rel_value) + if (0 == delay.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' timed out waiting for other peer to send CONNECT_ACK\n", @@ -2571,7 +2575,7 @@ master_task (void *cls, } break; case S_CONNECT_RECV_BLACKLIST_INBOUND: - if (0 == delay.rel_value) + if (0 == delay.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' timed out waiting BLACKLIST to approve address to use for received CONNECT\n", @@ -2582,7 +2586,7 @@ master_task (void *cls, } break; case S_CONNECT_RECV_ATS: - if (0 == delay.rel_value) + if (0 == delay.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' timed out waiting ATS to provide address to use for CONNECT_ACK\n", @@ -2593,7 +2597,7 @@ master_task (void *cls, } break; case S_CONNECT_RECV_BLACKLIST: - if (0 == delay.rel_value) + if (0 == delay.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' timed out waiting BLACKLIST to approve address to use for CONNECT_ACK\n", @@ -2604,7 +2608,7 @@ master_task (void *cls, } break; case S_CONNECT_RECV_ACK: - if (0 == delay.rel_value) + if (0 == delay.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' timed out waiting for other peer to send SESSION_ACK\n", @@ -2614,7 +2618,7 @@ master_task (void *cls, } break; case S_CONNECTED: - if (0 == delay.rel_value) + if (0 == delay.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs\n", @@ -2626,7 +2630,7 @@ master_task (void *cls, send_keepalive (n); break; case S_RECONNECT_ATS: - if (0 == delay.rel_value) + if (0 == delay.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' timed out, waiting for ATS replacement address\n", @@ -2636,7 +2640,7 @@ master_task (void *cls, } break; case S_RECONNECT_BLACKLIST: - if (0 == delay.rel_value) + if (0 == delay.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' timed out, waiting for BLACKLIST to approve replacement address\n", @@ -2646,7 +2650,7 @@ master_task (void *cls, } break; case S_RECONNECT_SENT: - if (0 == delay.rel_value) + if (0 == delay.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' timed out, waiting for other peer to CONNECT_ACK replacement address\n", @@ -2656,7 +2660,7 @@ master_task (void *cls, } break; case S_CONNECTED_SWITCHING_BLACKLIST: - if (0 == delay.rel_value) + if (0 == delay.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs\n", @@ -2668,7 +2672,7 @@ master_task (void *cls, send_keepalive (n); break; case S_CONNECTED_SWITCHING_CONNECT_SENT: - if (0 == delay.rel_value) + if (0 == delay.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs (after trying to CONNECT on alternative address)\n", @@ -2785,7 +2789,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, 1, GNUNET_NO); break; case S_CONNECT_SENT: - if (ts.abs_value != n->primary_address.connect_timestamp.abs_value) + if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us) break; /* ACK does not match our original CONNECT message */ n->state = S_CONNECTED; n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); @@ -3142,7 +3146,7 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity sdm = (const struct SessionDisconnectMessage *) msg; if (NULL == (n = lookup_neighbour (peer))) return; /* gone already */ - if (GNUNET_TIME_absolute_ntoh (sdm->timestamp).abs_value <= n->connect_ack_timestamp.abs_value) + if (GNUNET_TIME_absolute_ntoh (sdm->timestamp).abs_value_us <= n->connect_ack_timestamp.abs_value_us) { GNUNET_STATISTICS_update (GST_stats, gettext_noop diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 0c70ee9bb..95a7eb04a 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2010,2011 Christian Grothoff (and other contributing authors) + (C) 2010-2013 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -444,7 +444,7 @@ timeout_hello_validation (void *cls, ve->timeout_task = GNUNET_SCHEDULER_NO_TASK; max = GNUNET_TIME_absolute_max (ve->valid_until, ve->revalidation_block); left = GNUNET_TIME_absolute_get_remaining (max); - if (left.rel_value > 0) + if (left.rel_value_us > 0) { /* should wait a bit longer */ ve->timeout_task = @@ -494,7 +494,7 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid, GNUNET_i2s (pid), GST_plugins_a2s (ve->address), ve->address->transport_name); next = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), validation_delay); - if (next.abs_value > validation_next.abs_value) + if (next.abs_value_us > validation_next.abs_value_us) validation_next = next; /* We're going to send a PING so delay next validation */ slen = strlen (ve->address->transport_name) + 1; @@ -607,15 +607,15 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) canonical_delay = (ve->in_use == GNUNET_YES) ? CONNECTED_PING_FREQUENCY - : ((GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value > + : ((GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value_us > 0) ? VALIDATED_PING_FREQUENCY : UNVALIDATED_PING_KEEPALIVE); - if (delay.rel_value > canonical_delay.rel_value * 2) + if (delay.rel_value_us > canonical_delay.rel_value_us * 2) { /* situation changed, recalculate delay */ delay = canonical_delay; ve->revalidation_block = GNUNET_TIME_relative_to_absolute (delay); } - if (delay.rel_value > 0) + if (delay.rel_value_us > 0) { /* should wait a bit longer */ ve->revalidation_task = @@ -624,7 +624,7 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } blocked_for = GNUNET_TIME_absolute_get_remaining(validation_next); if ((validations_running > validations_fast_start_threshold) && - (blocked_for.rel_value > 0)) + (blocked_for.rel_value_us > 0)) { /* Validations are blocked, have to wait for blocked_for time */ ve->revalidation_task = @@ -636,24 +636,20 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* schedule next PINGing with some extra random delay to avoid synchronous re-validations */ rdelay = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - canonical_delay.rel_value); + canonical_delay.rel_value_us); - /* Debug code for mantis 0002726*/ - if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value == - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, rdelay).rel_value) + /* Debug code for mantis 0002726 */ + if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS, rdelay).rel_value_us) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Revalidation interval for peer `%s' for is FOREVER (debug: rdelay: %llu, canonical delay %llu)\n", - GNUNET_i2s (&ve->pid), - (unsigned long long) delay.rel_value, - (unsigned long long) canonical_delay.rel_value); + GNUNET_break (0); delay = canonical_delay; } else { - delay = GNUNET_TIME_relative_add (canonical_delay, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MILLISECONDS, rdelay)); + delay = GNUNET_TIME_relative_add (canonical_delay, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MICROSECONDS, rdelay)); } /* End debug code for mantis 0002726*/ ve->revalidation_task = @@ -739,7 +735,7 @@ add_valid_address (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Information ats; struct GNUNET_CRYPTO_EccPublicKey public_key; - if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) + if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) return GNUNET_OK; /* expired */ if ((GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid)) || (GNUNET_OK != GNUNET_HELLO_get_key (hello, &public_key))) @@ -806,16 +802,18 @@ GST_validation_start (unsigned int max_fds) * when doing to many validations in parallel: * if (running validations < (max_fds / 2)) * - "fast start": run validation immediately - * - have delay of (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value) / (max_fds / 2) + * - have delay of (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value_us) / (max_fds / 2) * (300 sec / ~150 == ~2 sec.) between two validations */ validation_next = GNUNET_TIME_absolute_get(); - validation_delay.rel_value = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value) / (max_fds / 2); + validation_delay.rel_value_us = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value_us) / (max_fds / 2); validations_fast_start_threshold = (max_fds / 2); validations_running = 0; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Validation uses a fast start threshold of %u connections and a delay between of %u ms\n ", - validations_fast_start_threshold, validation_delay.rel_value); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Validation uses a fast start threshold of %u connections and a delay between of %s\n ", + validations_fast_start_threshold, + GNUNET_STRINGS_relative_time_to_string (validation_delay, + GNUNET_YES)); validation_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE, GNUNET_NO); pnc = GNUNET_PEERINFO_notify (GST_cfg, GNUNET_YES, &process_peerinfo_hello, NULL); @@ -1056,8 +1054,8 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, GNUNET_assert (NULL != addrend); memcpy (&((char *) &pong[1])[slen], addrend, alen); } - if (GNUNET_TIME_absolute_get_remaining (*sig_cache_exp).rel_value < - PONG_SIGNATURE_LIFETIME.rel_value / 4) + if (GNUNET_TIME_absolute_get_remaining (*sig_cache_exp).rel_value_us < + PONG_SIGNATURE_LIFETIME.rel_value_us / 4) { /* create / update cached sig */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1164,7 +1162,7 @@ validate_address_iterator (void *cls, const struct ValidateAddressContext *vac = cls; struct ValidationEntry *ve; - if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) + if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) return GNUNET_OK; /* expired */ ve = find_validation_entry (&vac->public_key, address); if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task) @@ -1261,7 +1259,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, return; } if (GNUNET_TIME_absolute_get_remaining - (GNUNET_TIME_absolute_ntoh (pong->expiration)).rel_value == 0) + (GNUNET_TIME_absolute_ntoh (pong->expiration)).rel_value_us == 0) { GNUNET_STATISTICS_update (GST_stats, gettext_noop @@ -1272,7 +1270,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, sig_res = GNUNET_SYSERR; do_verify = GNUNET_YES; - if (0 != GNUNET_TIME_absolute_get_remaining(ve->pong_sig_valid_until).rel_value) + if (0 != GNUNET_TIME_absolute_get_remaining(ve->pong_sig_valid_until).rel_value_us) { /* We have a cached and valid signature for this peer, * try to compare instead of verify */ @@ -1316,7 +1314,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, { struct GNUNET_ATS_Information ats[2]; ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); - ats[0].value = htonl ((uint32_t) ve->latency.rel_value); + ats[0].value = htonl ((uint32_t) ve->latency.rel_value_us); ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); ats[1].value = htonl ((uint32_t) ve->network); GNUNET_ATS_address_add (GST_ats, ve->address, NULL, ats, 2); diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index c03d6a388..641261c05 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c @@ -264,14 +264,14 @@ shutdown_task (void *cls, { duration = GNUNET_TIME_absolute_get_duration (start_time); FPRINTF (stdout, _("Transmitted %llu bytes/s (%llu bytes in %s)\n"), - 1000 * traffic_sent / (1 + duration.rel_value), traffic_sent, + 1000LL * 1000LL * traffic_sent / (1 + duration.rel_value_us), traffic_sent, GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES)); } if (benchmark_receive) { duration = GNUNET_TIME_absolute_get_duration (start_time); FPRINTF (stdout, _("Received %llu bytes/s (%llu bytes in %s)\n"), - 1000 * traffic_received / (1 + duration.rel_value), + 1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us), traffic_received, GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES)); } diff --git a/src/transport/plugin_transport_bluetooth.c b/src/transport/plugin_transport_bluetooth.c index 41500c34e..74fcd36a7 100644 --- a/src/transport/plugin_transport_bluetooth.c +++ b/src/transport/plugin_transport_bluetooth.c @@ -694,7 +694,7 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) session->timeout_task = GNUNET_SCHEDULER_NO_TASK; timeout = GNUNET_TIME_absolute_get_remaining (session->timeout); - if (0 == timeout.rel_value) + if (0 == timeout.rel_value_us) { free_session (session); return; @@ -970,7 +970,7 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK; timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout); - if (0 == timeout.rel_value) + if (0 == timeout.rel_value_us) { free_macendpoint (endpoint); return; diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 88ab5cfed..937f4f62f 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -1261,8 +1261,10 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) s->timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_log (TIMEOUT_LOG, - "Session %p was idle for %llu ms, disconnecting\n", - s, (unsigned long long) TIMEOUT.rel_value); + "Session %p was idle for %s, disconnecting\n", + s, + GNUNET_STRINGS_relative_time_to_string (TIMEOUT, + GNUNET_YES)); /* call session destroy function */ if (s->inbound == GNUNET_NO) @@ -1284,8 +1286,10 @@ start_session_timeout (struct Session *s) &session_timeout, s); GNUNET_log (TIMEOUT_LOG, - "Timeout for session %p set to %llu ms\n", - s, (unsigned long long) TIMEOUT.rel_value); + "Timeout for session %p set to %s\n", + s, + GNUNET_STRINGS_relative_time_to_string (TIMEOUT, + GNUNET_YES)); } @@ -1303,8 +1307,10 @@ reschedule_session_timeout (struct Session *s) &session_timeout, s); GNUNET_log (TIMEOUT_LOG, - "Timeout rescheduled for session %p set to %llu ms\n", - s, (unsigned long long) TIMEOUT.rel_value); + "Timeout rescheduled for session %p set to %s\n", + s, + GNUNET_STRINGS_relative_time_to_String (TIMEOUT, + GNUNET_YES)); } diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 75daeab71..2d112d4fe 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c @@ -912,6 +912,7 @@ client_receive_mst_cb (void *cls, void *client, struct GNUNET_TIME_Relative delay; struct GNUNET_ATS_Information atsi; char *stat_txt; + if (GNUNET_YES != client_exist_session(p, s)) { GNUNET_break (0); @@ -940,14 +941,16 @@ client_receive_mst_cb (void *cls, void *client, s->next_receive = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); - if (GNUNET_TIME_absolute_get ().abs_value < s->next_receive.abs_value) + if (GNUNET_TIME_absolute_get ().abs_value_us < s->next_receive.abs_value_us) { - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, - "Client: peer `%s' address `%s' next read delayed for %llu ms\n", + "Client: peer `%s' address `%s' next read delayed for %s\n", GNUNET_i2s (&s->target), - http_common_plugin_address_to_string (NULL, s->plugin->protocol, s->addr, s->addrlen), - delay); + http_common_plugin_address_to_string (NULL, + s->plugin->protocol, + s->addr, s->addrlen), + GNUNET_STRINGS_relative_time_to_string (delay, + GNUNET_YES)); } client_reschedule_session_timeout (s); return GNUNET_OK; @@ -993,14 +996,16 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls) s, s->client_get, len, GNUNET_i2s (&s->target)); now = GNUNET_TIME_absolute_get (); - if (now.abs_value < s->next_receive.abs_value) + if (now.abs_value_us < s->next_receive.abs_value_us) { struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference (now, s->next_receive); GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, - "Session %p / connection %p: No inbound bandwidth available! Next read was delayed for %llu ms\n", - s, s->client_get, delta.rel_value); + "Session %p / connection %p: No inbound bandwidth available! Next read was delayed for %s\n", + s, s->client_get, + GNUNET_STRINGS_relative_time_to_string (delta, + GNUNET_YES)); if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (s->recv_wakeup_task); @@ -1276,7 +1281,7 @@ client_connect_get (struct Session *s) curl_easy_setopt (s->client_get, CURLOPT_TIMEOUT, 0); curl_easy_setopt (s->client_get, CURLOPT_PRIVATE, s); curl_easy_setopt (s->client_get, CURLOPT_CONNECTTIMEOUT_MS, - (long) HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value); + (long) HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL); curl_easy_setopt (s->client_get, CURLOPT_BUFFERSIZE, 2 * GNUNET_SERVER_MAX_MESSAGE_SIZE); #if CURL_TCP_NODELAY @@ -1353,7 +1358,7 @@ client_connect_put (struct Session *s) curl_easy_setopt (s->client_put, CURLOPT_TIMEOUT, 0); curl_easy_setopt (s->client_put, CURLOPT_PRIVATE, s); curl_easy_setopt (s->client_put, CURLOPT_CONNECTTIMEOUT_MS, - (long) HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value); + (long) HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL); curl_easy_setopt (s->client_put, CURLOPT_BUFFERSIZE, 2 * GNUNET_SERVER_MAX_MESSAGE_SIZE); #if CURL_TCP_NODELAY @@ -1597,8 +1602,10 @@ client_session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc s->timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_log (TIMEOUT_LOG, - "Session %p was idle for %llu ms, disconnecting\n", - s, (unsigned long long) CLIENT_SESSION_TIMEOUT.rel_value); + "Session %p was idle for %s, disconnecting\n", + s, + GNUNET_STRINGS_relative_time_to_string (CLIENT_SESSION_TIMEOUT, + GNUNET_YES)); /* call session destroy function */ GNUNET_assert (GNUNET_OK == client_disconnect (s)); @@ -1620,8 +1627,10 @@ client_start_session_timeout (struct Session *s) &client_session_timeout, s); GNUNET_log (TIMEOUT_LOG, - "Timeout for session %p set to %llu ms\n", - s, (unsigned long long) CLIENT_SESSION_TIMEOUT.rel_value); + "Timeout for session %p set to %s\n", + s, + GNUNET_STRINGS_relative_time_to_string (CLIENT_SESSION_TIMEOUT, + GNUNET_YES)); } @@ -1642,8 +1651,10 @@ client_reschedule_session_timeout (struct Session *s) &client_session_timeout, s); GNUNET_log (TIMEOUT_LOG, - "Timeout rescheduled for session %p set to %llu ms\n", - s, (unsigned long long) CLIENT_SESSION_TIMEOUT.rel_value); + "Timeout rescheduled for session %p set to %s\n", + s, + GNUNET_STRINGS_relative_time_to_string (CLIENT_SESSION_TIMEOUT, + GNUNET_YES)); } diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 19833521a..17e39360c 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet - (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors) + (C) 2002-2013 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -876,29 +876,42 @@ server_disconnect (struct Session *s) return GNUNET_OK; } + + +/** + * Tell MHD that the connection should timeout after #to seconds. + * + * @param plugin our plugin + * @param s session for which the timeout changes + * @param to timeout in seconds + */ static void -server_mhd_connection_timeout (struct HTTP_Server_Plugin *plugin, struct Session *s, int to) +server_mhd_connection_timeout (struct HTTP_Server_Plugin *plugin, + struct Session *s, + unsigned int to) { #if MHD_VERSION >= 0x00090E00 /* Setting timeouts for other connections */ - if (s->server_recv != NULL) - { - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, - "Setting timeout for %p to %u sec.\n", s->server_recv, to); - MHD_set_connection_option (s->server_recv->mhd_conn, - MHD_CONNECTION_OPTION_TIMEOUT, - to); - server_reschedule (plugin, s->server_recv->mhd_daemon, GNUNET_NO); - } - if (s->server_send != NULL) - { - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, - "Setting timeout for %p to %u sec.\n", s->server_send, to); - MHD_set_connection_option (s->server_send->mhd_conn, - MHD_CONNECTION_OPTION_TIMEOUT, - to); - server_reschedule (plugin, s->server_send->mhd_daemon, GNUNET_NO); - } + if (NULL != s->server_recv) + { + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, + "Setting timeout for %p to %u sec.\n", + s->server_recv, to); + MHD_set_connection_option (s->server_recv->mhd_conn, + MHD_CONNECTION_OPTION_TIMEOUT, + to); + server_reschedule (plugin, s->server_recv->mhd_daemon, GNUNET_NO); + } + if (NULL != s->server_send) + { + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, + "Setting timeout for %p to %u sec.\n", + s->server_send, to); + MHD_set_connection_option (s->server_send->mhd_conn, + MHD_CONNECTION_OPTION_TIMEOUT, + to); + server_reschedule (plugin, s->server_send->mhd_daemon, GNUNET_NO); + } #endif } @@ -1034,14 +1047,12 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin, struct ServerConnection *sc = NULL; const union MHD_ConnectionInfo *conn_info; struct GNUNET_ATS_Information ats; - struct HttpAddress *addr; size_t addr_len; - struct GNUNET_PeerIdentity target; uint32_t tag = 0; int direction = GNUNET_SYSERR; - int to; + unsigned int to; conn_info = MHD_get_connection_info (mhd_connection, MHD_CONNECTION_INFO_CLIENT_ADDRESS); @@ -1169,8 +1180,9 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin, #if MHD_VERSION >= 0x00090E00 if ((NULL == s->server_recv) || (NULL == s->server_send)) { - to = (HTTP_SERVER_NOT_VALIDATED_TIMEOUT.rel_value / 1000); - MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to); + to = (HTTP_SERVER_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL / 1000LL); + MHD_set_connection_option (mhd_connection, + MHD_CONNECTION_OPTION_TIMEOUT, to); server_reschedule (plugin, sc->mhd_daemon, GNUNET_NO); } else @@ -1178,7 +1190,7 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin, GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Session %p for peer `%s' fully connected\n", s, GNUNET_i2s (&target)); - to = (SERVER_SESSION_TIMEOUT.rel_value / 1000); + to = (SERVER_SESSION_TIMEOUT.rel_value_us / 1000LL / 1000LL); server_mhd_connection_timeout (plugin, s, to); } @@ -1325,13 +1337,14 @@ server_receive_mst_cb (void *cls, void *client, s->session_passed = GNUNET_YES; s->next_receive = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); - if (delay.rel_value > 0) + if (delay.rel_value_us > 0) { GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, - "Peer `%s' address `%s' next read delayed for %llu ms\n", + "Peer `%s' address `%s' next read delayed for %s\n", GNUNET_i2s (&s->target), http_common_plugin_address_to_string (NULL, p->protocol, s->addr, s->addrlen), - delay); + GNUNET_STRINGS_relative_time_to_string (delay, + GNUNET_YES)); } server_reschedule_session_timeout (s); return GNUNET_OK; @@ -1477,7 +1490,7 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, *upload_data_size); struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); - if ((s->next_receive.abs_value <= now.abs_value)) + if ((s->next_receive.abs_value_us <= now.abs_value_us)) { GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "PUT with %u bytes forwarded to MST\n", @@ -1488,16 +1501,17 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, } GNUNET_SERVER_mst_receive (s->msg_tk, s, upload_data, *upload_data_size, GNUNET_NO, GNUNET_NO); -#if MHD_VERSION >= 0x00090E00 - server_mhd_connection_timeout (plugin, s, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000); -#endif + server_mhd_connection_timeout (plugin, s, + GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value_us / 1000LL / 1000LL); (*upload_data_size) = 0; } else { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Session %p / Connection %p: no inbound bandwidth available! Next read was delayed by %llu ms\n", - s, sc, now.abs_value - s->next_receive.abs_value); + "Session %p / Connection %p: no inbound bandwidth available! Next read was delayed by %s\n", + s, sc, + GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (s->next_receive), + GNUNET_YES)); } return MHD_YES; } @@ -1753,12 +1767,12 @@ server_schedule (struct HTTP_Server_Plugin *plugin, { GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, - "SELECT Timeout changed from %llu to %llu\n", + "SELECT Timeout changed from %llu to %llu (ms)\n", last_timeout, timeout); last_timeout = timeout; } - if (timeout <= GNUNET_TIME_UNIT_SECONDS.rel_value) - tv.rel_value = (uint64_t) timeout; + if (timeout <= GNUNET_TIME_UNIT_SECONDS.rel_value_us / 1000LL) + tv.rel_value_us = (uint64_t) timeout * 1000LL; else tv = GNUNET_TIME_UNIT_SECONDS; } @@ -2007,12 +2021,12 @@ server_start (struct HTTP_Server_Plugin *plugin) #if MHD_VERSION >= 0x00090E00 - timeout = HTTP_SERVER_NOT_VALIDATED_TIMEOUT.rel_value / 1000; + timeout = HTTP_SERVER_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL / 1000LL; GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "MHD can set timeout per connection! Default time out %u sec.\n", timeout); #else - timeout = SERVER_SESSION_TIMEOUT.rel_value / 1000; + timeout = SERVER_SESSION_TIMEOUT.rel_value_us / 1000LL / 1000LL; GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name, "MHD cannot set timeout per connection! Default time out %u sec.\n", timeout); @@ -2870,8 +2884,10 @@ server_session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc s->timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_log (TIMEOUT_LOG, - "Session %p was idle for %llu ms, disconnecting\n", - s, (unsigned long long) SERVER_SESSION_TIMEOUT.rel_value); + "Session %p was idle for %s, disconnecting\n", + s, + GNUNET_STRINGS_relative_time_to_string (SERVER_SESSION_TIMEOUT, + GNUNET_YES)); /* call session destroy function */ GNUNET_assert (GNUNET_OK == server_disconnect (s)); @@ -2892,8 +2908,10 @@ server_start_session_timeout (struct Session *s) &server_session_timeout, s); GNUNET_log (TIMEOUT_LOG, - "Timeout for session %p set to %llu ms\n", - s, (unsigned long long) SERVER_SESSION_TIMEOUT.rel_value); + "Timeout for session %p set to %s\n", + s, + GNUNET_STRINGS_relative_time_to_string (SERVER_SESSION_TIMEOUT, + GNUNET_YES)); } @@ -2913,8 +2931,10 @@ server_reschedule_session_timeout (struct Session *s) &server_session_timeout, s); GNUNET_log (TIMEOUT_LOG, - "Timeout rescheduled for session %p set to %llu ms\n", - s, (unsigned long long) SERVER_SESSION_TIMEOUT.rel_value); + "Timeout rescheduled for session %p set to %s\n", + s, + GNUNET_STRINGS_relative_time_to_string (SERVER_SESSION_TIMEOUT, + GNUNET_YES)); } diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index dc0beb73f..b1c4cab2b 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet - (C) 2002--2012 Christian Grothoff (and other contributing authors) + (C) 2002--2013 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -897,7 +897,7 @@ do_transmit (void *cls, size_t size, void *buf) ret = 0; now = GNUNET_TIME_absolute_get (); while ((NULL != (pos = session->pending_messages_head)) && - (pos->timeout.abs_value <= now.abs_value)) + (pos->timeout.abs_value_us <= now.abs_value_us)) { GNUNET_CONTAINER_DLL_remove (session->pending_messages_head, session->pending_messages_tail, pos); @@ -2269,16 +2269,16 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client, reschedule_session_timeout (session); - if (delay.rel_value == 0) + if (0 == delay.rel_value_us) { GNUNET_SERVER_receive_done (client, GNUNET_OK); } else { LOG (GNUNET_ERROR_TYPE_DEBUG, - "Throttling receiving from `%s' for %llu ms\n", + "Throttling receiving from `%s' for %s\n", GNUNET_i2s (&session->target), - (unsigned long long) delay.rel_value); + GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); GNUNET_SERVER_disable_receive_done_warning (client); session->receive_delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_done, session); @@ -2426,8 +2426,10 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) s->timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Session %p was idle for %llu ms, disconnecting\n", - s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); + "Session %p was idle for %s, disconnecting\n", + s, + GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, + GNUNET_YES)); /* call session destroy function */ disconnect_session(s); } @@ -2445,8 +2447,10 @@ start_session_timeout (struct Session *s) &session_timeout, s); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Timeout for session %p set to %llu ms\n", - s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); + "Timeout for session %p set to %s\n", + s, + GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, + GNUNET_YES)); } @@ -2464,8 +2468,10 @@ reschedule_session_timeout (struct Session *s) &session_timeout, s); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Timeout rescheduled for session %p set to %llu ms\n", - s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); + "Timeout rescheduled for session %p set to %s\n", + s, + GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, + GNUNET_YES)); } @@ -2483,7 +2489,7 @@ stop_session_timeout (struct Session *s) s->timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout stopped for session %p canceled\n", - s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); + s); } } diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index be19c5de3..cb95a5a00 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet - (C) 2010, 2011 Christian Grothoff (and other contributing authors) + (C) 2010-2013 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -509,9 +509,9 @@ schedule_select (struct Plugin *plugin) * - timeout minimum delay */ plugin->select_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - (0 == min_delay.rel_value) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay, + (0 == min_delay.rel_value_us) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay, plugin->rs_v4, - (0 == min_delay.rel_value) ? plugin->ws_v4 : NULL, + (0 == min_delay.rel_value_us) ? plugin->ws_v4 : NULL, &udp_plugin_select, plugin); } if ((GNUNET_YES == plugin->enable_ipv6) && (NULL != plugin->sockv6)) @@ -525,9 +525,9 @@ schedule_select (struct Plugin *plugin) GNUNET_SCHEDULER_cancel(plugin->select_task_v6); plugin->select_task_v6 = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - (0 == min_delay.rel_value) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay, + (0 == min_delay.rel_value_us) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay, plugin->rs_v6, - (0 == min_delay.rel_value) ? plugin->ws_v6 : NULL, + (0 == min_delay.rel_value_us) ? plugin->ws_v6 : NULL, &udp_plugin_select_v6, plugin); } } @@ -1328,8 +1328,10 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) s->timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Session %p was idle for %llu ms, disconnecting\n", - s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); + "Session %p was idle for %s, disconnecting\n", + s, + GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, + GNUNET_YES)); /* call session destroy function */ disconnect_session (s); } @@ -1347,8 +1349,10 @@ start_session_timeout (struct Session *s) &session_timeout, s); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Timeout for session %p set to %llu ms\n", - s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); + "Timeout for session %p set to %s\n", + s, + GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, + GNUNET_YES)); } @@ -1366,8 +1370,10 @@ reschedule_session_timeout (struct Session *s) &session_timeout, s); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Timeout rescheduled for session %p set to %llu ms\n", - s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); + "Timeout rescheduled for session %p set to %s\n", + s, + GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, + GNUNET_YES)); } @@ -1385,7 +1391,7 @@ stop_session_timeout (struct Session *s) s->timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout stopped for session %p canceled\n", - s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); + s); } } @@ -2173,16 +2179,17 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) if (NULL == s) return; - if (s->flow_delay_for_other_peer.rel_value <= UINT32_MAX) - delay = s->flow_delay_for_other_peer.rel_value; + if (s->flow_delay_for_other_peer.rel_value_us <= UINT32_MAX) + delay = s->flow_delay_for_other_peer.rel_value_us; LOG (GNUNET_ERROR_TYPE_DEBUG, - "Sending ACK to `%s' including delay of %u ms\n", + "Sending ACK to `%s' including delay of %s\n", GNUNET_a2s (rc->src_addr, (rc->src_addr->sa_family == AF_INET) ? sizeof (struct sockaddr_in) : sizeof (struct sockaddr_in6)), - delay); + GNUNET_STRINGS_relative_time_to_string (s->flow_delay_for_other_peer, + GNUNET_YES)); udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msize); udpw->msg_size = msize; udpw->payload_size = 0; @@ -2248,10 +2255,11 @@ read_process_ack (struct Plugin *plugin, return; } - flow_delay.rel_value = (uint64_t) ntohl (udp_ack->delay); + flow_delay.rel_value_us = (uint64_t) ntohl (udp_ack->delay); LOG (GNUNET_ERROR_TYPE_DEBUG, - "We received a sending delay of %llu\n", - flow_delay.rel_value); + "We received a sending delay of %s\n", + GNUNET_STRINGS_relative_time_to_string (flow_delay, + GNUNET_YES)); s->flow_delay_from_other_peer = GNUNET_TIME_relative_to_absolute (flow_delay); @@ -2324,7 +2332,7 @@ read_process_fragment (struct Plugin *plugin, d_ctx->hnode = GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs, d_ctx, (GNUNET_CONTAINER_HeapCostType) - now.abs_value); + now.abs_value_us); LOG (GNUNET_ERROR_TYPE_DEBUG, "Created new defragmentation context for %u-byte fragment from `%s'\n", (unsigned int) ntohs (msg->size), @@ -2343,7 +2351,7 @@ read_process_fragment (struct Plugin *plugin, /* keep this 'rc' from expiring */ GNUNET_CONTAINER_heap_update_cost (plugin->defrag_ctxs, d_ctx->hnode, (GNUNET_CONTAINER_HeapCostType) - now.abs_value); + now.abs_value_us); } if (GNUNET_CONTAINER_heap_get_size (plugin->defrag_ctxs) > UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG) @@ -2459,7 +2467,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, { /* Find messages with timeout */ remaining = GNUNET_TIME_absolute_get_remaining (udpw->timeout); - if (GNUNET_TIME_UNIT_ZERO.rel_value == remaining.rel_value) + if (GNUNET_TIME_UNIT_ZERO.rel_value_us == remaining.rel_value_us) { /* Message timed out */ switch (udpw->msg_type) { @@ -2542,7 +2550,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, { /* Message did not time out, check flow delay */ remaining = GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer); - if (GNUNET_TIME_UNIT_ZERO.rel_value == remaining.rel_value) + if (GNUNET_TIME_UNIT_ZERO.rel_value_us == remaining.rel_value_us) { /* this message is not delayed */ LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -2554,8 +2562,10 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, { /* Message is delayed, try next */ LOG (GNUNET_ERROR_TYPE_DEBUG, - "Message for peer `%s' (%u bytes) is delayed for %llu \n", - GNUNET_i2s(&udpw->session->target), udpw->payload_size, remaining.rel_value); + "Message for peer `%s' (%u bytes) is delayed for %s\n", + GNUNET_i2s(&udpw->session->target), udpw->payload_size, + GNUNET_STRINGS_relative_time_to_string (remaining, + GNUNET_YES)); udpw = udpw->next; } } diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 19a4d8e60..211408f18 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c @@ -1080,7 +1080,7 @@ unix_plugin_select_write (struct Plugin *plugin) while (NULL != (msgw = plugin->msg_tail)) { - if (GNUNET_TIME_absolute_get_remaining (msgw->timeout).rel_value > 0) + if (GNUNET_TIME_absolute_get_remaining (msgw->timeout).rel_value_us > 0) break; /* Message is ready for sending */ /* Message has a timeout */ LOG (GNUNET_ERROR_TYPE_DEBUG, diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index a376a2642..42ed771f4 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c @@ -692,7 +692,7 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) session->timeout_task = GNUNET_SCHEDULER_NO_TASK; timeout = GNUNET_TIME_absolute_get_remaining (session->timeout); - if (0 == timeout.rel_value) + if (0 == timeout.rel_value_us) { free_session (session); return; @@ -1003,7 +1003,7 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK; timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout); - if (0 == timeout.rel_value) + if (0 == timeout.rel_value_us) { free_macendpoint (endpoint); return; diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index 37960e204..0dfe27c64 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c @@ -129,8 +129,8 @@ end () GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); - delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; - datarate = (total_bytes_sent * 1000) / delta; + delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; + datarate = (total_bytes_sent * 1000 * 1000) / delta; FPRINTF (stderr, "Throughput was %llu b/s\n", datarate); @@ -398,7 +398,7 @@ measure (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) measure_task = GNUNET_SCHEDULER_NO_TASK; counter++; - if ((DURATION.rel_value / 1000) < counter) + if ((DURATION.rel_value_us / 1000 / 1000LL) < counter) { FPRINTF (stderr, "%s", ".\n"); GNUNET_SCHEDULER_add_now (&end, NULL); diff --git a/src/transport/test_transport_api_manipulation_cfg.c b/src/transport/test_transport_api_manipulation_cfg.c index b7321af85..c9bb5d08a 100644 --- a/src/transport/test_transport_api_manipulation_cfg.c +++ b/src/transport/test_transport_api_manipulation_cfg.c @@ -25,8 +25,8 @@ * Peer 1 has inbound and outbound delay of 100ms * Peer 2 has no inbound and outbound delay * - * We send a request from P1 to P2 and expect delay of >= TEST_DELAY ms - * Then we send response from P2 to P1 and expect delay of >= TEST_DELAY ms + * We send a request from P1 to P2 and expect delay of >= TEST_DELAY us + * Then we send response from P2 to P1 and expect delay of >= TEST_DELAY us */ #include "platform.h" #include "gnunet_transport_service.h" @@ -48,7 +48,10 @@ #define TEST_RESPONSE_MESSAGE_TYPE 12346 -#define TEST_DELAY 100 +/** + * Test delay, in microseconds. + */ +#define TEST_DELAY 100 * 1000LL static char *test_source; @@ -304,16 +307,18 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, case TEST_REQUEST_MESSAGE_TYPE: duration = GNUNET_TIME_absolute_get_difference(start_request, GNUNET_TIME_absolute_get()); - if (duration.rel_value >= TEST_DELAY) + if (duration.rel_value_us >= TEST_DELAY) GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Request message was delayed for %llu ms\n", - duration.rel_value); + "Request message was delayed for %s\n", + GNUNET_STRINGS_relative_time_to_string (duration, + GNUNET_YES)); else - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Request message was delayed for %llu ms, should be %u ms\n", - duration.rel_value, TEST_DELAY); - ok = 1; + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Request message was delayed for unexpected duration %s\n", + GNUNET_STRINGS_relative_time_to_string (duration, + GNUNET_YES)); + ok = 1; } /* Send response */ @@ -323,15 +328,18 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, case TEST_RESPONSE_MESSAGE_TYPE: duration = GNUNET_TIME_absolute_get_difference(start_response, GNUNET_TIME_absolute_get()); - if (duration.rel_value >= TEST_DELAY) - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Response message was delayed for %llu ms\n", duration); + if (duration.rel_value_us >= TEST_DELAY) + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Response message was delayed for %s\n", + GNUNET_STRINGS_relative_time_to_string (duration, + GNUNET_YES)); else - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Response message was delayed for %llu ms, should be %u ms\n", - duration.rel_value, TEST_DELAY); - ok = 1; + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Response message was delayed for unexpected duration %s\n", + GNUNET_STRINGS_relative_time_to_string (duration, + GNUNET_YES)); + ok = 1; } /* Done */ ok = 0; diff --git a/src/transport/test_transport_api_manipulation_recv_tcp.c b/src/transport/test_transport_api_manipulation_recv_tcp.c index 83d1431dc..a91866be4 100644 --- a/src/transport/test_transport_api_manipulation_recv_tcp.c +++ b/src/transport/test_transport_api_manipulation_recv_tcp.c @@ -200,13 +200,14 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, /* Received non-delayed message */ dur_normal = GNUNET_TIME_absolute_get_duration(start_normal); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received non-delayed message %u after %llu\n", + "Received non-delayed message %u after %s\n", messages_recv, - (long long unsigned int) dur_normal.rel_value); + GNUNET_STRINGS_relative_time_to_string (dur_normal, + GNUNET_YES)); struct GNUNET_ATS_Information ats[2]; ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); - ats[0].value = htonl (1000); + ats[0].value = htonl (1000 * 1000LL); ats[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); ats[1].value = htonl (10); @@ -218,16 +219,18 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, /* Received manipulated message */ dur_delayed = GNUNET_TIME_absolute_get_duration(start_delayed); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received delayed message %u after %llu\n", + "Received delayed message %u after %s\n", messages_recv, - (long long unsigned int) dur_delayed.rel_value); - if (dur_delayed.rel_value < 1000) + GNUNET_STRINGS_relative_time_to_string (dur_delayed, + GNUNET_YES)); + if (dur_delayed.rel_value_us < 1000 * 1000LL) { - GNUNET_break (0); - ok += 1; + GNUNET_break (0); + ok += 1; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Delayed message was not delayed correctly: took only %llu\n", - (long long unsigned int) dur_delayed.rel_value); + "Delayed message was not delayed correctly: took only %s\n", + GNUNET_STRINGS_relative_time_to_string (dur_delayed, + GNUNET_YES)); } /* shutdown */ end (); diff --git a/src/transport/test_transport_api_manipulation_send_tcp.c b/src/transport/test_transport_api_manipulation_send_tcp.c index 5361e0aba..2b7fdc250 100644 --- a/src/transport/test_transport_api_manipulation_send_tcp.c +++ b/src/transport/test_transport_api_manipulation_send_tcp.c @@ -200,9 +200,10 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, /* Received non-delayed message */ dur_normal = GNUNET_TIME_absolute_get_duration(start_normal); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received non-delayed message %u after %llu\n", + "Received non-delayed message %u after %s\n", messages_recv, - (long long unsigned int) dur_normal.rel_value); + GNUNET_STRINGS_relative_time_to_string (dur_normal, + GNUNET_YES)); send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); } if (1 == messages_recv) @@ -210,16 +211,18 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, /* Received manipulated message */ dur_delayed = GNUNET_TIME_absolute_get_duration(start_delayed); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received delayed message %u after %llu\n", + "Received delayed message %u after %s\n", messages_recv, - (long long unsigned int) dur_delayed.rel_value); - if (dur_delayed.rel_value < 1000) + GNUNET_STRINGS_relative_time_to_string (dur_delayed, + GNUNET_YES)); + if (dur_delayed.rel_value_us < 1000 * 1000LL) { - GNUNET_break (0); - ok += 1; + GNUNET_break (0); + ok += 1; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Delayed message was not delayed correctly: took only %llu\n", - (long long unsigned int) dur_delayed.rel_value); + "Delayed message was not delayed correctly: took only %s\n", + GNUNET_STRINGS_relative_time_to_string (dur_delayed, + GNUNET_YES)); } /* shutdown */ @@ -291,7 +294,7 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (1 == messages_recv) { ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); - ats[0].value = htonl (1000); + ats[0].value = htonl (1000LL * 1000LL); GNUNET_TRANSPORT_set_traffic_metric (p2->th, &p1->id, GNUNET_NO, GNUNET_YES, ats, 1); ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); ats[0].value = htonl (10); diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index 2993a224d..d129350c2 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c @@ -123,11 +123,11 @@ end () GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); - delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; + delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; FPRINTF (stderr, "\nThroughput was %llu kb/s\n", - total_bytes * 1000 / 1024 / delta); + total_bytes * 1024 / delta); GNUNET_asprintf (&value_name, "reliable_%s", test_plugin); - GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), + GAUGER ("TRANSPORT", value_name, (int) (total_bytes / 1024 / delta), "kb/s"); GNUNET_free (value_name); diff --git a/src/transport/test_transport_api_timeout.c b/src/transport/test_transport_api_timeout.c index a3bef6b94..908374cb7 100644 --- a/src/transport/test_transport_api_timeout.c +++ b/src/transport/test_transport_api_timeout.c @@ -111,8 +111,10 @@ end () { ok = disconnects; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Fail! Had %u disconnects while waiting %llu seconds \n", - disconnects, WAIT.rel_value); + "Fail! Had %u disconnects while waiting %s\n", + disconnects, + GNUNET_STRINGS_relative_time_to_string (WAIT, + GNUNET_YES)); } GNUNET_TRANSPORT_TESTING_done (tth); @@ -193,8 +195,8 @@ timer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_TIME_relative_add (time_running, GNUNET_TIME_relative_divide (WAIT, 10)); - if (time_running.rel_value == - GNUNET_TIME_relative_max (time_running, WAIT).rel_value) + if (time_running.rel_value_us == + GNUNET_TIME_relative_max (time_running, WAIT).rel_value_us) { FPRINTF (stderr, "%s", "100%%\n"); shutdown_flag = GNUNET_YES; @@ -221,7 +223,10 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) shutdown_flag = GNUNET_NO; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting for %llu seconds\n", (WAIT.rel_value) / 1000); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Waiting for %s\n", + GNUNET_STRINGS_relative_time_to_string (WAIT, + GNUNET_YES)); if (die_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (die_task); diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c index afc26cef7..9bae154de 100644 --- a/src/transport/test_transport_api_unreliability.c +++ b/src/transport/test_transport_api_unreliability.c @@ -131,11 +131,11 @@ end () GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); - delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; + delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; FPRINTF (stderr, "\nThroughput was %llu kb/s\n", - total_bytes * 1000 / 1024 / delta); + total_bytes * 1024 / delta); GNUNET_asprintf (&value_name, "unreliable_%s", test_plugin); - GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), + GAUGER ("TRANSPORT", value_name, (int) (total_bytes / 1024 / delta), "kb/s"); GNUNET_free (value_name); diff --git a/src/transport/test_transport_api_unreliability_constant.c b/src/transport/test_transport_api_unreliability_constant.c index e5c244081..5217638c5 100644 --- a/src/transport/test_transport_api_unreliability_constant.c +++ b/src/transport/test_transport_api_unreliability_constant.c @@ -122,16 +122,15 @@ static void end () { unsigned long long delta; - char *value_name; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); - delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; + delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; FPRINTF (stderr, "\nThroughput was %llu kb/s\n", - total_bytes * 1000 / 1024 / delta); + total_bytes / 1024 / delta); GNUNET_asprintf (&value_name, "unreliable_%s", test_plugin); - GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), + GAUGER ("TRANSPORT", value_name, (int) (total_bytes / 1024 / delta), "kb/s"); GNUNET_free (value_name); diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index f92895c52..f83b6c098 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors) + (C) 2009-2013 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -744,7 +744,7 @@ transport_notify_ready (void *cls, size_t size, void *buf) if (th->notify_size + sizeof (struct OutboundMessage) > size) break; /* does not fit */ if (GNUNET_BANDWIDTH_tracker_get_delay - (&n->out_tracker, th->notify_size).rel_value > 0) + (&n->out_tracker, th->notify_size).rel_value_us > 0) break; /* too early */ GNUNET_assert (n == GNUNET_CONTAINER_heap_remove_root (h->ready_heap)); n->hn = NULL; @@ -801,7 +801,7 @@ schedule_transmission_task (void *cls, GNUNET_assert (NULL != h->client); /* destroy all requests that have timed out */ while ((NULL != (n = GNUNET_CONTAINER_heap_peek (h->ready_heap))) && - (GNUNET_TIME_absolute_get_remaining (n->th->timeout).rel_value == 0)) + (0 == GNUNET_TIME_absolute_get_remaining (n->th->timeout).rel_value_us)) { /* notify client that the request could not be satisfied within * the given time constraints */ @@ -868,8 +868,8 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h) else return; /* no work to be done */ LOG (GNUNET_ERROR_TYPE_DEBUG, - "Scheduling next transmission to service in %llu ms\n", - (unsigned long long) delay.rel_value); + "Scheduling next transmission to service in %s\n", + GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); h->quota_task = GNUNET_SCHEDULER_add_delayed (delay, &schedule_transmission_task, h); } @@ -1007,8 +1007,8 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h) GNUNET_free (th); } LOG (GNUNET_ERROR_TYPE_DEBUG, - "Scheduling task to reconnect to transport service in %llu ms.\n", - h->reconnect_delay.rel_value); + "Scheduling task to reconnect to transport service in %s.\n", + GNUNET_STRINGS_relative_time_to_string(h->reconnect_delay, GNUNET_YES)); h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay); @@ -1564,12 +1564,13 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle, /* calculate when our transmission should be ready */ delay = GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker, size + n->traffic_overhead); n->traffic_overhead = 0; - if (delay.rel_value > timeout.rel_value) - delay.rel_value = 0; /* notify immediately (with failure) */ + if (delay.rel_value_us > timeout.rel_value_us) + delay.rel_value_us = 0; /* notify immediately (with failure) */ LOG (GNUNET_ERROR_TYPE_DEBUG, - "Bandwidth tracker allows next transmission to peer %s in %llu ms\n", - GNUNET_i2s (target), (unsigned long long) delay.rel_value); - n->hn = GNUNET_CONTAINER_heap_insert (handle->ready_heap, n, delay.rel_value); + "Bandwidth tracker allows next transmission to peer %s in %s\n", + GNUNET_i2s (target), + GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); + n->hn = GNUNET_CONTAINER_heap_insert (handle->ready_heap, n, delay.rel_value_us); schedule_transmission (handle); return th; } |