summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-11 21:21:56 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-11 21:21:56 +0000
commit3d7fefedc9ba60bd8e8448efe8b628446d958536 (patch)
tree61ce41a52cd6e7232cead77818ef265993b2427e /src
parent4a0398474db197abed243a123fb971fbeeffab4b (diff)
changing time measurement from milliseconds to microseconds
Diffstat (limited to 'src')
-rw-r--r--src/arm/gnunet-arm.c10
-rw-r--r--src/arm/gnunet-service-arm.c9
-rw-r--r--src/arm/test_exponential_backoff.c4
-rw-r--r--src/ats/gnunet-service-ats-solver_mlp.c23
-rw-r--r--src/ats/gnunet-service-ats-solver_proportional.c9
-rw-r--r--src/ats/gnunet-service-ats_performance.c2
-rw-r--r--src/ats/gnunet-service-ats_reservations.c8
-rw-r--r--src/ats/perf_ats_mlp.c70
-rw-r--r--src/ats/test_ats_api_scheduling_block_and_reset.c105
-rw-r--r--src/ats/test_ats_api_scheduling_init.c4
-rw-r--r--src/core/gnunet-service-core_kx.c20
-rw-r--r--src/core/gnunet-service-core_sessions.c10
-rw-r--r--src/core/test_core_api_reliability.c6
-rw-r--r--src/core/test_core_quota_compliance.c6
-rw-r--r--src/datacache/perf_datacache.c4
-rw-r--r--src/datacache/plugin_datacache_heap.c4
-rw-r--r--src/datacache/plugin_datacache_postgres.c4
-rw-r--r--src/datacache/plugin_datacache_sqlite.c12
-rw-r--r--src/datacache/test_datacache.c2
-rw-r--r--src/datacache/test_datacache_quota.c2
-rw-r--r--src/datastore/datastore_api.c20
-rw-r--r--src/datastore/gnunet-service-datastore.c24
-rw-r--r--src/datastore/perf_datastore_api.c8
-rw-r--r--src/datastore/perf_plugin_datastore.c39
-rw-r--r--src/datastore/plugin_datastore_heap.c6
-rw-r--r--src/datastore/plugin_datastore_mysql.c19
-rw-r--r--src/datastore/plugin_datastore_postgres.c10
-rw-r--r--src/datastore/plugin_datastore_sqlite.c19
-rw-r--r--src/datastore/test_datastore_api.c13
-rw-r--r--src/datastore/test_datastore_api_management.c4
-rw-r--r--src/datastore/test_plugin_datastore.c5
-rw-r--r--src/dht/gnunet-service-dht_clients.c6
-rw-r--r--src/dht/gnunet-service-dht_hello.c2
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c10
-rw-r--r--src/dht/gnunet-service-dht_routing.c2
-rw-r--r--src/dns/dnsparser.c2
-rw-r--r--src/dns/dnsstub.c2
-rw-r--r--src/dns/gnunet-dns-monitor.c2
-rw-r--r--src/dns/plugin_block_dns.c2
-rw-r--r--src/exit/gnunet-daemon-exit.c4
-rw-r--r--src/experimentation/gnunet-daemon-experimentation_experiments.c12
-rw-r--r--src/experimentation/gnunet-daemon-experimentation_scheduler.c12
-rw-r--r--src/fragmentation/defragmentation.c10
-rw-r--r--src/fragmentation/fragmentation.c16
-rw-r--r--src/fs/fs_api.c12
-rw-r--r--src/fs/fs_download.c4
-rw-r--r--src/fs/fs_misc.c4
-rw-r--r--src/fs/fs_search.c6
-rw-r--r--src/fs/fs_uri.c7
-rw-r--r--src/fs/gnunet-daemon-fsprofiler.c11
-rw-r--r--src/fs/gnunet-download.c8
-rw-r--r--src/fs/gnunet-fs-profiler.c2
-rw-r--r--src/fs/gnunet-search.c2
-rw-r--r--src/fs/gnunet-service-fs.c10
-rw-r--r--src/fs/gnunet-service-fs_cp.c25
-rw-r--r--src/fs/gnunet-service-fs_pe.c46
-rw-r--r--src/fs/gnunet-service-fs_pr.c31
-rw-r--r--src/fs/gnunet-service-fs_push.c4
-rw-r--r--src/fs/perf_gnunet_service_fs_p2p.c6
-rw-r--r--src/fs/perf_gnunet_service_fs_p2p_respect.c6
-rw-r--r--src/fs/test_fs_download.c16
-rw-r--r--src/fs/test_fs_download_persistence.c8
-rw-r--r--src/fs/test_fs_list_indexed.c4
-rw-r--r--src/fs/test_fs_publish.c4
-rw-r--r--src/fs/test_fs_publish_persistence.c4
-rw-r--r--src/fs/test_fs_unindex.c8
-rw-r--r--src/fs/test_fs_unindex_persistence.c8
-rw-r--r--src/fs/test_gnunet_service_fs_migration.c6
-rw-r--r--src/fs/test_gnunet_service_fs_p2p.c8
-rw-r--r--src/gns/gnunet-dns2gns.c2
-rw-r--r--src/gns/gnunet-gns-fcfsd.c2
-rw-r--r--src/gns/gnunet-gns-proxy.c2
-rw-r--r--src/gns/gnunet-service-gns.c4
-rw-r--r--src/gns/gnunet-service-gns_interceptor.c4
-rw-r--r--src/gns/gnunet-service-gns_resolver.c45
-rw-r--r--src/gns/plugin_block_gns.c7
-rw-r--r--src/gns/test_gns_dht_three_peers.c5
-rw-r--r--src/gns/test_gns_proxy.c2
-rw-r--r--src/gns/test_gns_pseu_shorten.c2
-rw-r--r--src/gns/test_gns_simple_delegated_lookup.c2
-rw-r--r--src/gns/test_gns_simple_mx_lookup.c4
-rw-r--r--src/gns/test_gns_simple_srv_lookup.c4
-rw-r--r--src/hello/hello.c22
-rw-r--r--src/hostlist/hostlist-client.c29
-rw-r--r--src/hostlist/hostlist-server.c4
-rw-r--r--src/identity/identity_api.c2
-rw-r--r--src/include/gnunet_ats_service.h6
-rw-r--r--src/include/gnunet_client_lib.h2
-rw-r--r--src/include/gnunet_resolver_service.h4
-rw-r--r--src/include/gnunet_scheduler_lib.h4
-rw-r--r--src/include/gnunet_server_lib.h4
-rw-r--r--src/include/gnunet_time_lib.h38
-rw-r--r--src/mesh/gnunet-service-mesh-enc.c12
-rw-r--r--src/mesh/gnunet-service-mesh.c6
-rw-r--r--src/mesh/mesh_api.c2
-rw-r--r--src/mesh/mesh_api_enc.c2
-rw-r--r--src/mesh/test_mesh_small.c11
-rw-r--r--src/namestore/gnunet-namestore.c14
-rw-r--r--src/namestore/gnunet-service-namestore.c22
-rw-r--r--src/namestore/namestore_api_common.c6
-rw-r--r--src/namestore/plugin_namestore_postgres.c4
-rw-r--r--src/namestore/plugin_namestore_sqlite.c4
-rw-r--r--src/namestore/test_namestore_api.c2
-rw-r--r--src/namestore/test_namestore_api_create.c2
-rw-r--r--src/namestore/test_namestore_api_create_update.c4
-rw-r--r--src/namestore/test_namestore_api_lookup.c4
-rw-r--r--src/namestore/test_namestore_api_lookup_specific_type.c6
-rw-r--r--src/namestore/test_namestore_api_monitoring.c8
-rw-r--r--src/namestore/test_namestore_api_put.c4
-rw-r--r--src/namestore/test_namestore_api_remove.c6
-rw-r--r--src/namestore/test_namestore_api_remove_not_existing_record.c4
-rw-r--r--src/namestore/test_namestore_api_sign_verify.c2
-rw-r--r--src/namestore/test_namestore_api_zone_iteration.c17
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_specific_zone.c8
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_stop.c8
-rw-r--r--src/namestore/test_namestore_api_zone_to_name.c4
-rw-r--r--src/namestore/test_plugin_namestore.c2
-rw-r--r--src/nse/gnunet-nse-profiler.c5
-rw-r--r--src/nse/gnunet-service-nse.c63
-rw-r--r--src/nse/nse_api.c10
-rw-r--r--src/nse/perf_kdf.c2
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c4
-rw-r--r--src/pt/test_gns_vpn.c2
-rw-r--r--src/regex/gnunet-daemon-regexprofiler.c4
-rw-r--r--src/regex/plugin_block_regex.c2
-rw-r--r--src/sysmon/gnunet-service-sysmon.c16
-rw-r--r--src/testbed/gnunet-service-testbed_cpustatus.c4
-rw-r--r--src/testbed/testbed_api_hosts.c8
-rw-r--r--src/topology/gnunet-daemon-topology.c20
-rw-r--r--src/transport/gnunet-service-transport.c5
-rw-r--r--src/transport/gnunet-service-transport_manipulation.c35
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c62
-rw-r--r--src/transport/gnunet-service-transport_validation.c58
-rw-r--r--src/transport/gnunet-transport.c4
-rw-r--r--src/transport/plugin_transport_bluetooth.c4
-rw-r--r--src/transport/plugin_transport_http.c18
-rw-r--r--src/transport/plugin_transport_http_client.c43
-rw-r--r--src/transport/plugin_transport_http_server.c112
-rw-r--r--src/transport/plugin_transport_tcp.c30
-rw-r--r--src/transport/plugin_transport_udp.c60
-rw-r--r--src/transport/plugin_transport_unix.c2
-rw-r--r--src/transport/plugin_transport_wlan.c4
-rw-r--r--src/transport/test_quota_compliance.c6
-rw-r--r--src/transport/test_transport_api_manipulation_cfg.c46
-rw-r--r--src/transport/test_transport_api_manipulation_recv_tcp.c23
-rw-r--r--src/transport/test_transport_api_manipulation_send_tcp.c23
-rw-r--r--src/transport/test_transport_api_reliability.c6
-rw-r--r--src/transport/test_transport_api_timeout.c15
-rw-r--r--src/transport/test_transport_api_unreliability.c6
-rw-r--r--src/transport/test_transport_api_unreliability_constant.c7
-rw-r--r--src/transport/transport_api.c25
-rw-r--r--src/util/bandwidth.c48
-rw-r--r--src/util/client.c12
-rw-r--r--src/util/common_logging.c21
-rw-r--r--src/util/connection.c25
-rw-r--r--src/util/gnunet-service-resolver.c12
-rw-r--r--src/util/load.c16
-rw-r--r--src/util/network.c42
-rw-r--r--src/util/perf_crypto_hash.c6
-rw-r--r--src/util/perf_malloc.c10
-rw-r--r--src/util/resolver_api.c14
-rw-r--r--src/util/scheduler.c26
-rw-r--r--src/util/server.c10
-rw-r--r--src/util/speedup.c24
-rw-r--r--src/util/strings.c97
-rw-r--r--src/util/test_common_logging_dummy.c6
-rw-r--r--src/util/test_crypto_ecc.c6
-rw-r--r--src/util/test_scheduler_delay.c35
-rw-r--r--src/util/test_speedup.c27
-rw-r--r--src/util/test_strings.c6
-rw-r--r--src/util/test_time.c169
-rw-r--r--src/util/time.c111
-rw-r--r--src/vpn/gnunet-service-vpn.c14
173 files changed, 1432 insertions, 1216 deletions
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c
index 4a68a97ea..85cb1f45d 100644
--- a/src/arm/gnunet-arm.c
+++ b/src/arm/gnunet-arm.c
@@ -547,7 +547,7 @@ action_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Termination action\n");
GNUNET_ARM_request_service_stop (h, term,
- (0 == timeout.rel_value) ? STOP_TIMEOUT : timeout,
+ (0 == timeout.rel_value_us) ? STOP_TIMEOUT : timeout,
&term_callback, NULL);
return;
}
@@ -557,7 +557,7 @@ action_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "End action\n");
GNUNET_ARM_request_service_stop (h, "arm",
- (0 == timeout.rel_value) ? STOP_TIMEOUT_ARM : timeout,
+ (0 == timeout.rel_value_us) ? STOP_TIMEOUT_ARM : timeout,
&stop_callback, NULL);
return;
}
@@ -569,7 +569,7 @@ action_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_ARM_request_service_start (h, "arm",
(no_stdout ? 0 : GNUNET_OS_INHERIT_STD_OUT) |
(no_stderr ? 0 : GNUNET_OS_INHERIT_STD_ERR),
- (0 == timeout.rel_value) ? START_TIMEOUT: timeout,
+ (0 == timeout.rel_value_us) ? START_TIMEOUT: timeout,
start_callback, NULL);
return;
}
@@ -579,7 +579,7 @@ action_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initialization action\n");
GNUNET_ARM_request_service_start (h, init, GNUNET_OS_INHERIT_STD_NONE,
- (0 == timeout.rel_value) ? STOP_TIMEOUT : timeout,
+ (0 == timeout.rel_value_us) ? STOP_TIMEOUT : timeout,
&init_callback, NULL);
return;
}
@@ -590,7 +590,7 @@ action_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Going to list all running services controlled by ARM.\n");
GNUNET_ARM_request_service_list (h,
- (0 == timeout.rel_value) ? LIST_TIMEOUT : timeout,
+ (0 == timeout.rel_value_us) ? LIST_TIMEOUT : timeout,
&list_callback, &list);
return;
}
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index 1acb82f72..f5426e176 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -1012,8 +1012,7 @@ delayed_restart_task (void *cls,
if (NULL != sl->proc)
continue;
/* service is currently not running */
- if (GNUNET_TIME_absolute_get_remaining (sl->restart_at).rel_value ==
- 0)
+ if (0 == GNUNET_TIME_absolute_get_remaining (sl->restart_at).rel_value_us)
{
/* restart is now allowed */
if (sl->is_default)
@@ -1046,7 +1045,7 @@ delayed_restart_task (void *cls,
(sl->restart_at));
}
}
- if (lowestRestartDelay.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
+ if (lowestRestartDelay.rel_value_us != GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Will restart process in %s\n",
@@ -1126,7 +1125,7 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
statstr = _( /* process termination method */ "unknown");
statcode = 0;
}
- if (0 != pos->killed_at.abs_value)
+ if (0 != pos->killed_at.abs_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Service `%s' took %s to terminate\n"),
@@ -1149,7 +1148,7 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if ((statusType == GNUNET_OS_PROCESS_EXITED) && (statcode == 0))
{
/* process terminated normally, allow restart at any time */
- pos->restart_at.abs_value = 0;
+ pos->restart_at.abs_value_us = 0;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Service `%s' terminated normally, will restart at any time\n"),
pos->name);
diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c
index c61bc2eec..7d8d771a2 100644
--- a/src/arm/test_exponential_backoff.c
+++ b/src/arm/test_exponential_backoff.c
@@ -250,7 +250,7 @@ kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc)
}
else
{
- waitedFor.rel_value = 0;
+ waitedFor.rel_value_us = 0;
}
/* Connect to the doNothing task */
doNothingConnection = GNUNET_CLIENT_connect ("do-nothing", cfg);
@@ -261,7 +261,7 @@ kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_CLIENT_disconnect (doNothingConnection);
GNUNET_ARM_request_service_stop (arm, "do-nothing", TIMEOUT, NULL, NULL);
- if (waitedFor_prev.rel_value >= waitedFor.rel_value)
+ if (waitedFor_prev.rel_value_us >= waitedFor.rel_value_us)
ok = 9;
else
ok = 0;
diff --git a/src/ats/gnunet-service-ats-solver_mlp.c b/src/ats/gnunet-service-ats-solver_mlp.c
index 84cacd017..93c6839f8 100644
--- a/src/ats/gnunet-service-ats-solver_mlp.c
+++ b/src/ats/gnunet-service-ats-solver_mlp.c
@@ -1078,7 +1078,7 @@ GAS_mlp_solve_problem (void *solver)
else
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem was updated, resolving\n");
- duration_build.rel_value = 0;
+ duration_build.rel_value_us = 0;
}
/* Run LP solver */
@@ -1107,10 +1107,15 @@ GAS_mlp_solve_problem (void *solver)
mlp->ps.p_rows = glp_get_num_rows (mlp->p.prob);
mlp->ps.p_elements = mlp->p.num_elements;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Execution time: Build %llu ms, LP %llu ms, MLP %llu ms\n",
- (unsigned long long) duration_build.rel_value,
- (unsigned long long) duration_lp.rel_value,
- (unsigned long long) duration_mlp.rel_value);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Execution time: Build %s\n",
+ GNUNET_STRINGS_relative_time_to_string (duration_build, GNUNET_NO));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Execution time: LP %s\n",
+ GNUNET_STRINGS_relative_time_to_string (duration_lp, GNUNET_NO));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Execution time: MLP %s\n",
+ GNUNET_STRINGS_relative_time_to_string (duration_mlp, GNUNET_NO));
/* Propagate result*/
if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip))
@@ -1120,7 +1125,7 @@ GAS_mlp_solve_problem (void *solver)
if (GNUNET_YES == mlp->write_mip_mps)
{
/* Write problem to disk */
- GNUNET_asprintf (&filename, "problem_p_%u_a%u_%llu.mps", mlp->p.num_peers, mlp->p.num_addresses, time.abs_value);
+ GNUNET_asprintf (&filename, "problem_p_%u_a%u_%llu.mps", mlp->p.num_peers, mlp->p.num_addresses, time.abs_value_us);
LOG (GNUNET_ERROR_TYPE_ERROR, "DUMP: %s \n", filename);
glp_write_lp(mlp->p.prob, NULL, filename);
GNUNET_free (filename);
@@ -1128,7 +1133,7 @@ GAS_mlp_solve_problem (void *solver)
if (GNUNET_YES == mlp->write_mip_sol)
{
/* Write solution to disk */
- GNUNET_asprintf (&filename, "problem_p_%u_a%u_%llu.sol", mlp->p.num_peers, mlp->p.num_addresses, time.abs_value);
+ GNUNET_asprintf (&filename, "problem_p_%u_a%u_%llu.sol", mlp->p.num_peers, mlp->p.num_addresses, time.abs_value_us);
glp_print_mip (mlp->p.prob, filename );
LOG (GNUNET_ERROR_TYPE_ERROR, "DUMP: %s \n", filename);
GNUNET_free (filename);
@@ -1965,7 +1970,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
mlp->control_param_lp.msg_lev = GLP_MSG_ALL;
#endif
mlp->control_param_lp.it_lim = max_iterations;
- mlp->control_param_lp.tm_lim = max_duration.rel_value;
+ mlp->control_param_lp.tm_lim = max_duration.rel_value_us / 1000LL;
/* Init MLP solving parameters */
glp_init_iocp(&mlp->control_param_mlp);
@@ -1973,7 +1978,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
#if VERBOSE_GLPK
mlp->control_param_mlp.msg_lev = GLP_MSG_ALL;
#endif
- mlp->control_param_mlp.tm_lim = max_duration.rel_value;
+ mlp->control_param_mlp.tm_lim = max_duration.rel_value_us / 1000LL;
LOG (GNUNET_ERROR_TYPE_DEBUG, "solver ready\n");
diff --git a/src/ats/gnunet-service-ats-solver_proportional.c b/src/ats/gnunet-service-ats-solver_proportional.c
index a48714855..1a1d5cad4 100644
--- a/src/ats/gnunet-service-ats-solver_proportional.c
+++ b/src/ats/gnunet-service-ats-solver_proportional.c
@@ -596,13 +596,14 @@ find_best_address_it (void *cls, const struct GNUNET_HashCode * key, void *value
now = GNUNET_TIME_absolute_get();
- if (current->blocked_until.abs_value == GNUNET_TIME_absolute_max (now, current->blocked_until).abs_value)
+ if (current->blocked_until.abs_value_us == GNUNET_TIME_absolute_max (now, current->blocked_until).abs_value_us)
{
/* This address is blocked for suggestion */
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Address %p blocked for suggestion for %llu ms \n",
- current,
- GNUNET_TIME_absolute_get_difference(now, current->blocked_until).rel_value);
+ "Address %p blocked for suggestion for %s \n",
+ current,
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (now, current->blocked_until),
+ GNUNET_YES));
return GNUNET_OK;
}
if (GNUNET_NO == is_bandwidth_available_in_network (net))
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c
index 4164e5f0d..f0986959c 100644
--- a/src/ats/gnunet-service-ats_performance.c
+++ b/src/ats/gnunet-service-ats_performance.c
@@ -582,7 +582,7 @@ GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
"RESERVATION_REQUEST");
amount = (int32_t) ntohl (msg->amount);
res_delay = GAS_reservations_reserve (&msg->peer, amount);
- if (res_delay.rel_value > 0)
+ if (res_delay.rel_value_us > 0)
amount = 0;
result.header.size = htons (sizeof (struct ReservationResultMessage));
result.header.type = htons (GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT);
diff --git a/src/ats/gnunet-service-ats_reservations.c b/src/ats/gnunet-service-ats_reservations.c
index 3354c4e41..0b4948576 100644
--- a/src/ats/gnunet-service-ats_reservations.c
+++ b/src/ats/gnunet-service-ats_reservations.c
@@ -63,11 +63,13 @@ GAS_reservations_reserve (const struct GNUNET_PeerIdentity *peer,
if (amount >= 0)
{
ret = GNUNET_BANDWIDTH_tracker_get_delay (tracker, amount);
- if (ret.rel_value > 0)
+ if (ret.rel_value_us > 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Delay to satisfy reservation for %d bytes is %llu ms\n",
- (int) amount, (unsigned long long) ret.rel_value);
+ "Delay to satisfy reservation for %d bytes is %s\n",
+ (int) amount,
+ GNUNET_STRINGS_relative_time_to_string (ret,
+ GNUNET_YES));
return ret;
}
}
diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c
index ada67fc94..5d370104b 100644
--- a/src/ats/perf_ats_mlp.c
+++ b/src/ats/perf_ats_mlp.c
@@ -366,39 +366,51 @@ check (void *cls, char *const *args, const char *cfgfile,
}
if (GNUNET_NO == opt_numeric)
{
- fprintf (stderr, "Rebuild: %03u peers each %02u addresses; rebuild: LP/MIP state [%3s/%3s] presolv [%3s/%3s], (build/LP/MIP in ms) %04llu / %04llu / %04llu\n",
- cp + 1, ca,
- (GNUNET_OK == full_lp_res) ? "OK" : "FAIL",
- (GNUNET_OK == full_mip_res) ? "OK" : "FAIL",
- (GLP_YES == full_lp_presolv) ? "YES" : "NO",
- (GNUNET_OK == full_mip_presolv) ? "YES" : "NO",
- (unsigned long long) full_build_dur.rel_value, (unsigned long long) full_lp_dur.rel_value, (unsigned long long) full_mip_dur.rel_value);
+ fprintf (stderr,
+ "Rebuild: %03u peers each %02u addresses; rebuild: LP/MIP state [%3s/%3s] presolv [%3s/%3s], (build/LP/MIP in us) %04llu / %04llu / %04llu\n",
+ cp + 1, ca,
+ (GNUNET_OK == full_lp_res) ? "OK" : "FAIL",
+ (GNUNET_OK == full_mip_res) ? "OK" : "FAIL",
+ (GLP_YES == full_lp_presolv) ? "YES" : "NO",
+ (GNUNET_OK == full_mip_presolv) ? "YES" : "NO",
+ (unsigned long long) full_build_dur.rel_value_us,
+ (unsigned long long) full_lp_dur.rel_value_us,
+ (unsigned long long) full_mip_dur.rel_value_us);
if ((0 < opt_update_quantity) || (0 < opt_update_percent))
- fprintf (stderr, "Update : %03u peers each %02u addresses; rebuild: LP/MIP state [%3s/%3s] presolv [%3s/%3s], (build/LP/MIP in ms) %04llu / %04llu / %04llu\n",
- cp + 1, ca,
- (GNUNET_OK == update_lp_res) ? "OK" : "FAIL",
- (GNUNET_OK == update_mip_res) ? "OK" : "FAIL",
- (GLP_YES == update_lp_presolv) ? "YES" : "NO",
- (GNUNET_OK == update_mip_presolv) ? "YES" : "NO",
- (unsigned long long) update_build_dur.rel_value, (unsigned long long) update_lp_dur.rel_value, (unsigned long long) update_mip_dur.rel_value);
+ fprintf (stderr,
+ "Update: %03u peers each %02u addresses; rebuild: LP/MIP state [%3s/%3s] presolv [%3s/%3s], (build/LP/MIP in us) %04llu / %04llu / %04llu\n",
+ cp + 1, ca,
+ (GNUNET_OK == update_lp_res) ? "OK" : "FAIL",
+ (GNUNET_OK == update_mip_res) ? "OK" : "FAIL",
+ (GLP_YES == update_lp_presolv) ? "YES" : "NO",
+ (GNUNET_OK == update_mip_presolv) ? "YES" : "NO",
+ (unsigned long long) update_build_dur.rel_value_us,
+ (unsigned long long) update_lp_dur.rel_value_us,
+ (unsigned long long) update_mip_dur.rel_value_us);
}
else
{
- fprintf (stderr, "Rebuild;%u;%u;%s;%s;%s;%s;%04llu;%04llu;%04llu\n",
- cp + 1, ca,
- (GNUNET_OK == full_lp_res) ? "OK" : "FAIL",
- (GNUNET_OK == full_mip_res) ? "OK" : "FAIL",
- (GLP_YES == full_lp_presolv) ? "YES" : "NO",
- (GNUNET_OK == full_mip_presolv) ? "YES" : "NO",
- (unsigned long long) full_build_dur.rel_value, (unsigned long long) full_lp_dur.rel_value, (unsigned long long) full_mip_dur.rel_value);
- if ((0 < opt_update_quantity) || (0 < opt_update_percent))
- fprintf (stderr, "Update;%u;%u;%s;%s;%s;%s;%04llu;%04llu;%04llu\n",
- cp + 1, ca,
- (GNUNET_OK == update_lp_res) ? "OK" : "FAIL",
- (GNUNET_OK == update_mip_res) ? "OK" : "FAIL",
- (GLP_YES == update_lp_presolv) ? "YES" : "NO",
- (GNUNET_OK == update_mip_presolv) ? "YES" : "NO",
- (unsigned long long) update_build_dur.rel_value, (unsigned long long) update_lp_dur.rel_value, (unsigned long long) update_mip_dur.rel_value);
+ fprintf (stderr,
+ "Rebuild;%u;%u;%s;%s;%s;%s;%04llu;%04llu;%04llu\n",
+ cp + 1, ca,
+ (GNUNET_OK == full_lp_res) ? "OK" : "FAIL",
+ (GNUNET_OK == full_mip_res) ? "OK" : "FAIL",
+ (GLP_YES == full_lp_presolv) ? "YES" : "NO",
+ (GNUNET_OK == full_mip_presolv) ? "YES" : "NO",
+ (unsigned long long) full_build_dur.rel_value_us,
+ (unsigned long long) full_lp_dur.rel_value_us,
+ (unsigned long long) full_mip_dur.rel_value_us);
+ if ((0 < opt_update_quantity) || (0 < opt_update_percent))
+ fprintf (stderr,
+ "Update;%u;%u;%s;%s;%s;%s;%04llu;%04llu;%04llu\n",
+ cp + 1, ca,
+ (GNUNET_OK == update_lp_res) ? "OK" : "FAIL",
+ (GNUNET_OK == update_mip_res) ? "OK" : "FAIL",
+ (GLP_YES == update_lp_presolv) ? "YES" : "NO",
+ (GNUNET_OK == update_mip_presolv) ? "YES" : "NO",
+ (unsigned long long) update_build_dur.rel_value_us,
+ (unsigned long long) update_lp_dur.rel_value_us,
+ (unsigned long long) update_mip_dur.rel_value_us);
}
}
}
diff --git a/src/ats/test_ats_api_scheduling_block_and_reset.c b/src/ats/test_ats_api_scheduling_block_and_reset.c
index b799a5de3..d5bd58031 100644
--- a/src/ats/test_ats_api_scheduling_block_and_reset.c
+++ b/src/ats/test_ats_api_scheduling_block_and_reset.c
@@ -150,44 +150,48 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
if (3 == stage)
{
/* Suggestion after resetting block interval */
- reset_block_duration = GNUNET_TIME_absolute_get_difference(reset_block_start, GNUNET_TIME_absolute_get());
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Address suggestion after resetting blocking took about %llu ms!\n",
- (long long unsigned int) reset_block_duration.rel_value);
- if ((block_duration.rel_value <= (initial_duration.rel_value * 3)) ||
- (initial_duration.rel_value <= (block_duration.rel_value * 3)))
+ reset_block_duration = GNUNET_TIME_absolute_get_difference (reset_block_start,
+ GNUNET_TIME_absolute_get());
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Address suggestion after resetting blocking took about %s!\n",
+ GNUNET_STRINGS_relative_time_to_string (reset_block_duration,
+ GNUNET_YES));
+ if ((block_duration.rel_value_us <= (initial_duration.rel_value_us * 3)) ||
+ (initial_duration.rel_value_us <= (block_duration.rel_value_us * 3)))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Address suggestion after resetting blocking (%llu ms) took about the same as initial suggestion (%llu ms)\n",
- (long long unsigned int) reset_block_duration.rel_value,
- (long long unsigned int) initial_duration.rel_value);
+ "Address suggestion after resetting blocking took about the same as initial suggestion (%s)\n",
+ GNUNET_STRINGS_relative_time_to_string (initial_duration,
+ GNUNET_YES));
ret = 0;
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Address suggestion after resetting blocking (%llu ms) has too big difference to initial suggestion (%llu ms)\n",
- (long long unsigned int) reset_block_duration.rel_value,
- (long long unsigned int) initial_duration.rel_value);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Address suggestion after resetting blocking has too big difference to initial suggestion (%s)\n",
+ GNUNET_STRINGS_relative_time_to_string (initial_duration,
+ GNUNET_YES));
ret = 1;
GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
GNUNET_SCHEDULER_add_now (&end, NULL);
return;
}
- if (((initial_duration.rel_value * 3) <= block_duration.rel_value ) &&
- ((reset_block_duration.rel_value * 3) <= block_duration.rel_value))
+ if (((initial_duration.rel_value_us * 3) <= block_duration.rel_value_us) &&
+ ((reset_block_duration.rel_value_us * 3) <= block_duration.rel_value_us))
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Address suggestion after resetting blocking (%llu ms) and initial suggestion (%llu ms) much faster than with blocking (%llu ms)\n",
- (long long unsigned int) reset_block_duration.rel_value,
- (long long unsigned int) initial_duration.rel_value,
- (long long unsigned int) block_duration.rel_value);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Address suggestion after resetting blocking and initial suggestion (%llu us) much faster than with blocking (%llu us)\n",
+ (unsigned long long) initial_duration.rel_value_us,
+ (unsigned long long) block_duration.rel_value_us);
ret = 0;
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Address suggestion after resetting blocking (%llu ms) and initial suggestion (%llu ms) not faster than with blocking (%llu ms)\n",
- (long long unsigned int) reset_block_duration.rel_value,
- (long long unsigned int) initial_duration.rel_value,
- (long long unsigned int) block_duration.rel_value);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Address suggestion after resetting blocking and initial suggestion (%llu us) not faster than with blocking (%llu us)\n",
+ (unsigned long long) initial_duration.rel_value_us,
+ (unsigned long long) block_duration.rel_value_us);
ret = 1;
}
@@ -200,18 +204,22 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
{
/* Suggestion after block*/
block_duration = GNUNET_TIME_absolute_get_difference(block_start, GNUNET_TIME_absolute_get());
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Address suggestion was blocked for about %llu ms!\n",
- (long long unsigned int) block_duration.rel_value);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Address suggestion was blocked for about %s!\n",
+ GNUNET_STRINGS_relative_time_to_string (block_duration,
+ GNUNET_YES));
if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n", stage,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Stage %u: Callback with correct address `%s'\n", stage,
GNUNET_i2s (&address->peer));
ret = 0;
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n", stage,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Stage %u: Callback with invalid address `%s'\n", stage,
GNUNET_i2s (&address->peer));
GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
GNUNET_SCHEDULER_add_now (&end, NULL);
@@ -220,7 +228,8 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Stage %u: Callback with incorrect ats info \n");
GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
GNUNET_SCHEDULER_add_now (&end, NULL);
ret = 1;
@@ -237,13 +246,17 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
/* Initial suggestion */
if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n", stage,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Stage %u: Callback with correct address `%s'\n",
+ stage,
GNUNET_i2s (&address->peer));
ret = 0;
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n", stage,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Stage %u: Callback with invalid address `%s'\n",
+ stage,
GNUNET_i2s (&address->peer));
GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
GNUNET_SCHEDULER_add_now (&end, NULL);
@@ -252,15 +265,20 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Stage %u: Callback with incorrect ats info\n",
+ stage);
GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
GNUNET_SCHEDULER_add_now (&end, NULL);
ret = 1;
}
- stage ++;
+ stage++;
initial_duration = GNUNET_TIME_absolute_get_difference(initial_start, GNUNET_TIME_absolute_get());
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u: Initial suggestion took about %llu ms\n", stage,
- (long long unsigned int) block_duration.rel_value);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Stage %u: Initial suggestion took about %s\n",
+ stage,
+ GNUNET_STRINGS_relative_time_to_string (block_duration,
+ GNUNET_YES));
block_start = GNUNET_TIME_absolute_get();
wait_task = GNUNET_SCHEDULER_add_delayed (WAIT, &request_task, NULL);
@@ -270,22 +288,28 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
/* Startup suggestion */
if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n", stage,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Stage %u: Callback with correct address `%s'\n",
+ stage,
GNUNET_i2s (&address->peer));
ret = 0;
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n", stage,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Stage %u: Callback with invalid address `%s'\n",
+ stage,
GNUNET_i2s (&address->peer));
GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
GNUNET_SCHEDULER_add_now (&end, NULL);
ret = 1;
}
- if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
+ if (GNUNET_OK != compare_ats (atsi, ats_count, test_ats_info, test_ats_count))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Stage %u: Callback with incorrect ats info\n",
+ stage);
GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
GNUNET_SCHEDULER_add_now (&end, NULL);
ret = 1;
@@ -312,7 +336,8 @@ run (void *cls,
sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
if (sched_ats == NULL)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not connect to ATS scheduling!\n");
ret = 1;
end ();
return;
@@ -321,14 +346,16 @@ run (void *cls,
/* Set up peer */
if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.id.hashPubKey))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not setup peer!\n");
ret = GNUNET_SYSERR;
end ();
return;
}
GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p.id)));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Created peer `%s'\n",
GNUNET_i2s_full(&p.id));
/* Prepare ATS Information */
diff --git a/src/ats/test_ats_api_scheduling_init.c b/src/ats/test_ats_api_scheduling_init.c
index bd96a4df7..6d6505100 100644
--- a/src/ats/test_ats_api_scheduling_init.c
+++ b/src/ats/test_ats_api_scheduling_init.c
@@ -123,7 +123,9 @@ run (void *cls,
end_badly_now ();
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting for %llu sec\n", (long long unsigned int) DELAY.rel_value);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting for %s\n",
+ GNUNET_STRINGS_relative_time_to_string (DELAY,
+ GNUNET_YES));
wait_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &delay, NULL);
}
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c
index d574d3762..879939b18 100644
--- a/src/core/gnunet-service-core_kx.c
+++ b/src/core/gnunet-service-core_kx.c
@@ -756,7 +756,7 @@ GSC_KX_handle_ephemeral_key (struct GSC_KeyExchangeInfo *kx,
if ( ( (KX_STATE_KEY_RECEIVED == kx->status) ||
(KX_STATE_UP == kx->status) ||
(KX_STATE_REKEY_SENT == kx->status) ) &&
- (end_t.abs_value <= kx->foreign_key_expires.abs_value) )
+ (end_t.abs_value_us <= kx->foreign_key_expires.abs_value_us) )
{
GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# old ephemeral keys ignored"),
1, GNUNET_NO);
@@ -796,15 +796,15 @@ GSC_KX_handle_ephemeral_key (struct GSC_KeyExchangeInfo *kx,
return;
}
now = GNUNET_TIME_absolute_get ();
- if ( (end_t.abs_value < GNUNET_TIME_absolute_subtract (now, REKEY_TOLERANCE).abs_value) ||
- (start_t.abs_value > GNUNET_TIME_absolute_add (now, REKEY_TOLERANCE).abs_value) )
+ if ( (end_t.abs_value_us < GNUNET_TIME_absolute_subtract (now, REKEY_TOLERANCE).abs_value_us) ||
+ (start_t.abs_value_us > GNUNET_TIME_absolute_add (now, REKEY_TOLERANCE).abs_value_us) )
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Ephemeral key message from peer `%s' rejected as its validity range does not match our system time (%llu not in [%llu,%llu]).\n"),
GNUNET_i2s (&kx->peer),
- now.abs_value,
- start_t.abs_value,
- end_t.abs_value);
+ now.abs_value_us,
+ start_t.abs_value_us,
+ end_t.abs_value_us);
return;
}
if (GNUNET_OK !=
@@ -994,7 +994,7 @@ send_keep_alive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
kx->keep_alive_task = GNUNET_SCHEDULER_NO_TASK;
left = GNUNET_TIME_absolute_get_remaining (kx->timeout);
- if (0 == left.rel_value)
+ if (0 == left.rel_value_us)
{
GNUNET_STATISTICS_update (GSC_stats,
gettext_noop ("# sessions terminated by timeout"),
@@ -1300,7 +1300,7 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
1, GNUNET_NO);
return;
}
- if (0 == GNUNET_TIME_absolute_get_remaining (kx->foreign_key_expires).rel_value)
+ if (0 == GNUNET_TIME_absolute_get_remaining (kx->foreign_key_expires).rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Session to peer `%s' went down due to key expiration (should not happen)\n"),
@@ -1394,8 +1394,8 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
/* check timestamp */
t = GNUNET_TIME_absolute_ntoh (pt->timestamp);
- if (GNUNET_TIME_absolute_get_duration (t).rel_value >
- MAX_MESSAGE_AGE.rel_value)
+ if (GNUNET_TIME_absolute_get_duration (t).rel_value_us >
+ MAX_MESSAGE_AGE.rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Message received far too old (%s). Content ignored.\n",
diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c
index bf27d5600..a77919bde 100644
--- a/src/core/gnunet-service-core_sessions.c
+++ b/src/core/gnunet-service-core_sessions.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
@@ -240,8 +240,8 @@ transmit_typemap_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
delay = TYPEMAP_FREQUENCY;
}
/* randomize a bit to avoid spont. sync */
- delay.rel_value +=
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000);
+ delay.rel_value_us +=
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000 * 1000);
session->typemap_task =
GNUNET_SCHEDULER_add_delayed (delay, &transmit_typemap_task, session);
GNUNET_STATISTICS_update (GSC_stats,
@@ -409,7 +409,7 @@ discard_expired_requests (struct Session *session)
{
pos = nxt;
nxt = pos->next;
- if ((pos->deadline.abs_value < now.abs_value) &&
+ if ((pos->deadline.abs_value_us < now.abs_value_us) &&
(GNUNET_YES != pos->was_solicited))
{
GNUNET_STATISTICS_update (GSC_stats,
@@ -501,7 +501,7 @@ try_transmission (struct Session *session)
now = GNUNET_TIME_absolute_get ();
if ((msize == 0) ||
((msize < GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE / 2) &&
- (min_deadline.abs_value > now.abs_value)))
+ (min_deadline.abs_value_us > now.abs_value_us)))
{
/* not enough ready yet, try to solicit more */
solicit_messages (session);
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index 149a49225..29f39585e 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -127,10 +127,10 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
p1.th = NULL;
GNUNET_TRANSPORT_disconnect (p2.th);
p2.th = NULL;
- 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);
- GAUGER ("CORE", "Core throughput/s", total_bytes * 1000 / 1024 / delta,
+ total_bytes * 1000000LL / 1024 / delta);
+ GAUGER ("CORE", "Core throughput/s", total_bytes * 1000000LL / 1024 / delta,
"kb/s");
ok = 0;
}
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c
index e09417642..9eb4d841f 100644
--- a/src/core/test_core_quota_compliance.c
+++ b/src/core/test_core_quota_compliance.c
@@ -231,10 +231,10 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
FPRINTF (stdout, "%s", "\n");
running = GNUNET_NO;
- delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value;
+ delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us;
- throughput_out = total_bytes_sent * 1000 / delta; /* convert to bytes/s */
- throughput_in = total_bytes_recv * 1000 / delta; /* convert to bytes/s */
+ throughput_out = total_bytes_sent * 1000000LL / delta; /* convert to bytes/s */
+ throughput_in = total_bytes_recv * 1000000LL / delta; /* convert to bytes/s */
max_quota_in = GNUNET_MIN (current_quota_p1_in, current_quota_p2_in);
max_quota_out = GNUNET_MIN (current_quota_p1_out, current_quota_p2_out);
diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c
index 84775a314..027999d22 100644
--- a/src/datacache/perf_datacache.c
+++ b/src/datacache/perf_datacache.c
@@ -96,7 +96,7 @@ run (void *cls, char *const *args, const char *cfgfile,
GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES));
GNUNET_snprintf (gstr, sizeof (gstr), "DATACACHE-%s", plugin_name);
GAUGER (gstr, "Time to PUT item in datacache",
- GNUNET_TIME_absolute_get_duration (start).rel_value / ITERATIONS,
+ GNUNET_TIME_absolute_get_duration (start).rel_value_us / 1000LL / ITERATIONS,
"ms/item");
start = GNUNET_TIME_absolute_get ();
memset (&k, 0, sizeof (struct GNUNET_HashCode));
@@ -116,7 +116,7 @@ run (void *cls, char *const *args, const char *cfgfile,
ITERATIONS - found);
if (found > 0)
GAUGER (gstr, "Time to GET item from datacache",
- GNUNET_TIME_absolute_get_duration (start).rel_value / found,
+ GNUNET_TIME_absolute_get_duration (start).rel_value_us / 1000LL / found,
"ms/item");
GNUNET_DATACACHE_destroy (h);
ASSERT (ok == 0);
diff --git a/src/datacache/plugin_datacache_heap.c b/src/datacache/plugin_datacache_heap.c
index 41dd08974..aee6cd5b8 100644
--- a/src/datacache/plugin_datacache_heap.c
+++ b/src/datacache/plugin_datacache_heap.c
@@ -182,7 +182,7 @@ put_cb (void *cls,
put_ctx->path_info_len * sizeof (struct GNUNET_PeerIdentity));
GNUNET_CONTAINER_heap_update_cost (put_ctx->heap,
val->hn,
- val->discard_time.abs_value);
+ val->discard_time.abs_value_us);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Got same value for key %s and type %d (size %u vs %u)\n",
GNUNET_h2s (key),
@@ -250,7 +250,7 @@ heap_plugin_put (void *cls, const struct GNUNET_HashCode * key, size_t size,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
val->hn = GNUNET_CONTAINER_heap_insert (plugin->heap,
val,
- val->discard_time.abs_value);
+ val->discard_time.abs_value_us);
return size + OVERHEAD;
}
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c
index e7d2e72c2..c8d66ead1 100644
--- a/src/datacache/plugin_datacache_postgres.c
+++ b/src/datacache/plugin_datacache_postgres.c
@@ -176,7 +176,7 @@ postgres_plugin_put (void *cls, const struct GNUNET_HashCode * key, size_t size,
struct Plugin *plugin = cls;
PGresult *ret;
uint32_t btype = htonl (type);
- uint64_t bexpi = GNUNET_TIME_absolute_hton (discard_time).abs_value__;
+ uint64_t bexpi = GNUNET_TIME_absolute_hton (discard_time).abs_value_us__;
const char *paramValues[] = {
(const char *) &btype,
@@ -277,7 +277,7 @@ postgres_plugin_get (void *cls, const struct GNUNET_HashCode * key,
}
for (i = 0; i < cnt; i++)
{
- expiration_time.abs_value =
+ expiration_time.abs_value_us =
GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, i, 0));
type = ntohl (*(uint32_t *) PQgetvalue (res, i, 1));
size = PQgetlength (res, i, 2);
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c
index bf76f310f..34aa61363 100644
--- a/src/datacache/plugin_datacache_sqlite.c
+++ b/src/datacache/plugin_datacache_sqlite.c
@@ -116,7 +116,7 @@ sqlite_plugin_put (void *cls,
"Processing `%s' of %u bytes with key `%4s' and expiration %s\n",
"PUT", (unsigned int) size, GNUNET_h2s (key),
GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (discard_time), GNUNET_YES));
- dval = (int64_t) discard_time.abs_value;
+ dval = (int64_t) discard_time.abs_value_us;
if (dval < 0)
dval = INT64_MAX;
if (sq_prepare
@@ -203,13 +203,13 @@ sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key,
"sq_prepare");
return 0;
}
- ntime = (int64_t) now.abs_value;
+ ntime = (int64_t) now.abs_value_us;
GNUNET_assert (ntime >= 0);
if ((SQLITE_OK !=
sqlite3_bind_blob (stmt, 1, key, sizeof (struct GNUNET_HashCode),
SQLITE_TRANSIENT)) ||
(SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) ||
- (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value)))
+ (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value_us)))
{
LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_bind_xxx");
@@ -256,7 +256,7 @@ sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key,
sqlite3_bind_blob (stmt, 1, key, sizeof (struct GNUNET_HashCode),
SQLITE_TRANSIENT)) ||
(SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) ||
- (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value)))
+ (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value_us)))
{
LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_bind_xxx");
@@ -267,7 +267,7 @@ sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key,
break;
size = sqlite3_column_bytes (stmt, 0);
dat = sqlite3_column_blob (stmt, 0);
- exp.abs_value = sqlite3_column_int64 (stmt, 1);
+ exp.abs_value_us = sqlite3_column_int64 (stmt, 1);
psize = sqlite3_column_bytes (stmt, 2);
if (0 != psize % sizeof (struct GNUNET_PeerIdentity))
{
@@ -279,7 +279,7 @@ sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key,
path = sqlite3_column_blob (stmt, 2);
else
path = NULL;
- ntime = (int64_t) exp.abs_value;
+ ntime = (int64_t) exp.abs_value_us;
if (ntime == INT64_MAX)
exp = GNUNET_TIME_UNIT_FOREVER_ABS;
cnt++;
diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c
index 8c429cc7a..071ae721f 100644
--- a/src/datacache/test_datacache.c
+++ b/src/datacache/test_datacache.c
@@ -80,7 +80,7 @@ run (void *cls, char *const *args, const char *cfgfile,
return;
}
exp = GNUNET_TIME_absolute_get ();
- exp.abs_value += 5 * 60 * 1000;
+ exp.abs_value_us += 5 * 60 * 1000 * 1000LL;
memset (&k, 0, sizeof (struct GNUNET_HashCode));
for (i = 0; i < 100; i++)
{
diff --git a/src/datacache/test_datacache_quota.c b/src/datacache/test_datacache_quota.c
index 0400b5051..877c62a3f 100644
--- a/src/datacache/test_datacache_quota.c
+++ b/src/datacache/test_datacache_quota.c
@@ -71,7 +71,7 @@ run (void *cls, char *const *args, const char *cfgfile,
GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n);
for (j = i; j < sizeof (buf); j += 10)
{
- exp.abs_value++;
+ exp.abs_value_us++;
buf[j] = i;
ASSERT (GNUNET_OK == GNUNET_DATACACHE_put (h, &k, j, buf, 1 + i, exp, 0, NULL));
ASSERT (0 < GNUNET_DATACACHE_get (h, &k, 1 + i, NULL, NULL));
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index fab3bf0ca..2fb250b96 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -850,9 +850,10 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, uint32_t rid,
union QueueContext qc;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Asked to put %u bytes of data under key `%s' for %llu ms\n", size,
+ "Asked to put %u bytes of data under key `%s' for %s\n", size,
GNUNET_h2s (key),
- GNUNET_TIME_absolute_get_remaining (expiration).rel_value);
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration),
+ GNUNET_YES));
msize = sizeof (struct DataMessage) + size;
GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
qc.sc.cont = cont;
@@ -1037,8 +1038,10 @@ GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, uint64_t uid,
if (cont == NULL)
cont = &drop_status_cont;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Asked to update entry %llu raising priority by %u and expiration to %llu\n",
- uid, (unsigned int) priority, (unsigned long long) expiration.abs_value);
+ "Asked to update entry %llu raising priority by %u and expiration to %s\n",
+ uid,
+ (unsigned int) priority,
+ GNUNET_STRINGS_absolute_time_to_string (expiration));
qc.sc.cont = cont;
qc.sc.cont_cls = cont_cls;
qe = make_queue_entry (h, sizeof (struct UpdateMessage), queue_priority,
@@ -1268,8 +1271,9 @@ GNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h,
union QueueContext qc;
GNUNET_assert (NULL != proc);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to get replication entry in %llu ms\n",
- (unsigned long long) timeout.rel_value);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Asked to get replication entry in %s\n",
+ GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_YES));
qc.rc.proc = proc;
qc.rc.proc_cls = proc_cls;
qe = make_queue_entry (h, sizeof (struct GNUNET_MessageHeader),
@@ -1330,9 +1334,9 @@ GNUNET_DATASTORE_get_zero_anonymity (struct GNUNET_DATASTORE_Handle *h,
GNUNET_assert (NULL != proc);
GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Asked to get %llu-th zero-anonymity entry of type %d in %llu ms\n",
+ "Asked to get %llu-th zero-anonymity entry of type %d in %s\n",
(unsigned long long) offset, type,
- (unsigned long long) timeout.rel_value);
+ GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_YES));
qc.rc.proc = proc;
qc.rc.proc_cls = proc_cls;
qe = make_queue_entry (h, sizeof (struct GetZeroAnonymityMessage),
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 93b43b16c..f6018b7b5 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -332,7 +332,7 @@ expired_processor (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
return GNUNET_SYSERR;
}
now = GNUNET_TIME_absolute_get ();
- if (expiration.abs_value > now.abs_value)
+ if (expiration.abs_value_us > now.abs_value_us)
{
/* finished processing */
expired_kill_task =
@@ -342,9 +342,11 @@ expired_processor (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
return GNUNET_SYSERR;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Deleting content `%s' of type %u that expired %llu ms ago\n",
+ "Deleting content `%s' of type %u that expired %s ago\n",
GNUNET_h2s (key), type,
- (unsigned long long) (now.abs_value - expiration.abs_value));
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (expiration,
+ now),
+ GNUNET_YES));
min_expiration = now;
GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes expired"), size,
GNUNET_YES);
@@ -404,11 +406,12 @@ quota_processor (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
if (NULL == key)
return GNUNET_SYSERR;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Deleting %llu bytes of low-priority (%u) content `%s' of type %u at %llu ms prior to expiration (still trying to free another %llu bytes)\n",
+ "Deleting %llu bytes of low-priority (%u) content `%s' of type %u at %s prior to expiration (still trying to free another %llu bytes)\n",
(unsigned long long) (size + GNUNET_DATASTORE_ENTRY_OVERHEAD),
(unsigned int) priority,
GNUNET_h2s (key), type,
- (unsigned long long) GNUNET_TIME_absolute_get_remaining (expiration).rel_value,
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration),
+ GNUNET_YES),
*need);
if (size + GNUNET_DATASTORE_ENTRY_OVERHEAD > *need)
*need = 0;
@@ -619,10 +622,11 @@ transmit_item (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
dm->key = *key;
memcpy (&dm[1], data, size);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Transmitting `%s' message for `%s' of type %u with expiration %llu (now: %llu)\n",
+ "Transmitting `%s' message for `%s' of type %u with expiration %s (in: %s)\n",
"DATA", GNUNET_h2s (key), type,
- (unsigned long long) expiration.abs_value,
- (unsigned long long) GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_STRINGS_absolute_time_to_string (expiration),
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration),
+ GNUNET_YES));
GNUNET_STATISTICS_update (stats, gettext_noop ("# results found"), 1,
GNUNET_NO);
transmit (client, &dm->header);
@@ -896,8 +900,8 @@ check_present (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
"Result already present in datastore\n");
/* FIXME: change API to allow increasing 'replication' counter */
if ((ntohl (dm->priority) > 0) ||
- (GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value >
- expiration.abs_value))
+ (GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value_us >
+ expiration.abs_value_us))
plugin->api->update (plugin->api->cls, uid,
(int32_t) ntohl (dm->priority),
GNUNET_TIME_absolute_ntoh (dm->expiration), NULL);
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index cf21ebe44..83be3ad5f 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -245,9 +245,9 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
#endif
"Stored %llu kB / %lluk ops / %llu ops/s\n", stored_bytes / 1024, /* used size in k */
stored_ops / 1024, /* total operations (in k) */
- 1000 * stored_ops / (1 +
- GNUNET_TIME_absolute_get_duration
- (start_time).rel_value));
+ 1000LL * 1000LL * stored_ops / (1 +
+ GNUNET_TIME_absolute_get_duration
+ (start_time).rel_value_us));
crc->phase = RP_PUT;
crc->j = 0;
GNUNET_SCHEDULER_add_continuation (&run_continuation, crc,
@@ -257,7 +257,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_snprintf (gstr, sizeof (gstr), "DATASTORE-%s", plugin_name);
if ((crc->i == ITERATIONS) && (stored_ops > 0))
GAUGER (gstr, "PUT operation duration",
- GNUNET_TIME_absolute_get_duration (start_time).rel_value /
+ GNUNET_TIME_absolute_get_duration (start_time).rel_value_us / 1000LL /
stored_ops, "ms/operation");
GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES);
GNUNET_free (crc);
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c
index 322ca26b2..657acc66b 100644
--- a/src/datastore/perf_plugin_datastore.c
+++ b/src/datastore/perf_plugin_datastore.c
@@ -115,7 +115,7 @@ putValue (struct GNUNET_DATASTORE_PluginFunctions *api, int i, int k)
size = size - (size & 7); /* always multiple of 8 */
/* generate random key */
- key.bits[0] = (unsigned int) GNUNET_TIME_absolute_get ().abs_value;
+ key.bits[0] = (unsigned int) GNUNET_TIME_absolute_get ().abs_value_us;
GNUNET_CRYPTO_hash (&key, sizeof (struct GNUNET_HashCode), &key);
memset (value, i, size);
if (i > 255)
@@ -164,9 +164,10 @@ iterate_zeros (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
hits[i / 8] |= (1 << (i % 8));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Found result %d type=%u, priority=%u, size=%u, expire=%llu\n",
+ "Found result %d type=%u, priority=%u, size=%u, expire=%s\n",
i,
- type, priority, size, (unsigned long long) expiration.abs_value);
+ type, priority, size,
+ GNUNET_STRINGS_absolute_time_to_string (expiration));
crc->cnt++;
if (crc->cnt == PUT_10 / 4 - 1)
{
@@ -178,13 +179,15 @@ iterate_zeros (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
bc++;
crc->end = GNUNET_TIME_absolute_get ();
- printf ("%s took %llu ms yielding %u/%u items\n",
+ printf ("%s took %s yielding %u/%u items\n",
"Select random zero-anonymity item",
- (unsigned long long) (crc->end.abs_value - crc->start.abs_value),
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (crc->start,
+ crc->end),
+ GNUNET_YES),
bc, crc->cnt);
if (crc->cnt > 0)
GAUGER (category, "Select random zero-anonymity item",
- (crc->end.abs_value - crc->start.abs_value) / crc->cnt,
+ (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / crc->cnt,
"ms/item");
memset (hits, 0, sizeof (hits));
crc->phase++;
@@ -220,13 +223,15 @@ expiration_get (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
bc++;
crc->end = GNUNET_TIME_absolute_get ();
- printf ("%s took %llu ms yielding %u/%u items\n",
+ printf ("%s took %s yielding %u/%u items\n",
"Selecting and deleting by expiration",
- (unsigned long long) (crc->end.abs_value - crc->start.abs_value),
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (crc->start,
+ crc->end),
+ GNUNET_YES),
bc, (unsigned int) PUT_10);
if (crc->cnt > 0)
GAUGER (category, "Selecting and deleting by expiration",
- (crc->end.abs_value - crc->start.abs_value) / crc->cnt,
+ (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / crc->cnt,
"ms/item");
memset (hits, 0, sizeof (hits));
if (++crc->iter == ITERATIONS)
@@ -266,13 +271,15 @@ replication_get (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
bc++;
crc->end = GNUNET_TIME_absolute_get ();
- printf ("%s took %llu ms yielding %u/%u items\n",
+ printf ("%s took %s yielding %u/%u items\n",
"Selecting random item for replication",
- (unsigned long long) (crc->end.abs_value - crc->start.abs_value),
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (crc->start,
+ crc->end),
+ GNUNET_YES),
bc, (unsigned int) PUT_10);
if (crc->cnt > 0)
GAUGER (category, "Selecting random item for replication",
- (crc->end.abs_value - crc->start.abs_value) / crc->cnt,
+ (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / crc->cnt,
"ms/item");
memset (hits, 0, sizeof (hits));
crc->phase++;
@@ -359,12 +366,14 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
putValue (crc->api, j, crc->i);
crc->end = GNUNET_TIME_absolute_get ();
{
- printf ("%s took %llu ms for %llu items\n", "Storing an item",
- (unsigned long long) (crc->end.abs_value - crc->start.abs_value),
+ printf ("%s took %s for %llu items\n", "Storing an item",
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (crc->start,
+ crc->end),
+ GNUNET_YES),
PUT_10);
if (PUT_10 > 0)
GAUGER (category, "Storing an item",
- (crc->end.abs_value - crc->start.abs_value) / PUT_10,
+ (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / PUT_10,
"ms/item");
}
crc->i++;
diff --git a/src/datastore/plugin_datastore_heap.c b/src/datastore/plugin_datastore_heap.c
index 9f9360bfb..79dcb9043 100644
--- a/src/datastore/plugin_datastore_heap.c
+++ b/src/datastore/plugin_datastore_heap.c
@@ -226,7 +226,7 @@ heap_plugin_put (void *cls,
value->data = &value[1];
value->expire_heap = GNUNET_CONTAINER_heap_insert (plugin->by_expiration,
value,
- expiration.abs_value);
+ expiration.abs_value_us);
value->replication_heap = GNUNET_CONTAINER_heap_insert (plugin->by_replication,
value,
replication);
@@ -628,12 +628,12 @@ heap_plugin_update (void *cls,
value = (struct Value*) (long) uid;
GNUNET_assert (NULL != value);
- if (value->expiration.abs_value != expire.abs_value)
+ if (value->expiration.abs_value_us != expire.abs_value_us)
{
value->expiration = expire;
GNUNET_CONTAINER_heap_update_cost (plugin->by_expiration,
value->expire_heap,
- expire.abs_value);
+ expire.abs_value_us);
}
if ( (delta < 0) && (value->priority < - delta) )
value->priority = 0;
diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c
index ad70e73d4..40f25deee 100644
--- a/src/datastore/plugin_datastore_mysql.c
+++ b/src/datastore/plugin_datastore_mysql.c
@@ -290,7 +290,7 @@ mysql_plugin_put (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
unsigned int irepl = replication;
unsigned int ipriority = priority;
unsigned int ianonymity = anonymity;
- unsigned long long lexpiration = expiration.abs_value;
+ unsigned long long lexpiration = expiration.abs_value_us;
unsigned long long lrvalue =
(unsigned long long) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
UINT64_MAX);
@@ -358,12 +358,13 @@ mysql_plugin_update (void *cls, uint64_t uid, int delta,
{
struct Plugin *plugin = cls;
unsigned long long vkey = uid;
- unsigned long long lexpire = expire.abs_value;
+ unsigned long long lexpire = expire.abs_value_us;
int ret;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Updating value %llu adding %d to priority and maxing exp at %llu\n",
- vkey, delta, lexpire);
+ "Updating value %llu adding %d to priority and maxing exp at %s\n",
+ vkey, delta,
+ GNUNET_STRINGS_absolute_time_to_string (expire));
ret =
GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->update_entry, NULL,
MYSQL_TYPE_LONG, &delta, GNUNET_NO,
@@ -449,11 +450,13 @@ execute_select (struct Plugin *plugin, struct GNUNET_MYSQL_StatementHandle *stmt
proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
+ expiration.abs_value_us = exp;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Found %u-byte value under key `%s' with prio %u, anon %u, expire %llu selecting from gn090 table\n",
- (unsigned int) size, GNUNET_h2s (&key), priority, anonymity, exp);
+ "Found %u-byte value under key `%s' with prio %u, anon %u, expire %s selecting from gn090 table\n",
+ (unsigned int) size, GNUNET_h2s (&key),
+ priority, anonymity,
+ GNUNET_STRINGS_absolute_time_to_string (expiration));
GNUNET_assert (size < MAX_DATUM_SIZE);
- expiration.abs_value = exp;
ret =
proc (proc_cls, &key, size, value, type, priority, anonymity, expiration,
uid);
@@ -907,7 +910,7 @@ mysql_plugin_get_expiration (void *cls, PluginDatumProcessor proc,
rc.plugin = plugin;
rc.proc = proc;
rc.proc_cls = proc_cls;
- nt = (long long) GNUNET_TIME_absolute_get ().abs_value;
+ nt = (long long) GNUNET_TIME_absolute_get ().abs_value_us;
execute_select (plugin, plugin->select_expiration, expi_proc, &rc,
MYSQL_TYPE_LONGLONG, &nt, GNUNET_YES, -1);
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c
index 83fc423da..98109d4da 100644
--- a/src/datastore/plugin_datastore_postgres.c
+++ b/src/datastore/plugin_datastore_postgres.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- (C) 2009, 2010, 2011, 2012 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
@@ -283,7 +283,7 @@ postgres_plugin_put (void *cls, const struct GNUNET_HashCode * key, uint32_t siz
uint32_t bprio = htonl (priority);
uint32_t banon = htonl (anonymity);
uint32_t brepl = htonl (replication);
- uint64_t bexpi = GNUNET_TIME_absolute_hton (expiration).abs_value__;
+ uint64_t bexpi = GNUNET_TIME_absolute_hton (expiration).abs_value_us__;
const char *paramValues[] = {
(const char *) &brepl,
@@ -392,7 +392,7 @@ process_result (struct Plugin *plugin, PluginDatumProcessor proc,
type = ntohl (*(uint32_t *) PQgetvalue (res, 0, 0));
priority = ntohl (*(uint32_t *) PQgetvalue (res, 0, 1));
anonymity = ntohl (*(uint32_t *) PQgetvalue (res, 0, 2));
- expiration_time.abs_value =
+ expiration_time.abs_value_us =
GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, 0, 3));
memcpy (&key, PQgetvalue (res, 0, 4), sizeof (struct GNUNET_HashCode));
size = PQgetlength (res, 0, 5);
@@ -712,7 +712,7 @@ postgres_plugin_get_expiration (void *cls, PluginDatumProcessor proc,
const char *paramValues[] = { (const char *) &btime };
PGresult *ret;
- btime = GNUNET_htonll (GNUNET_TIME_absolute_get ().abs_value);
+ btime = GNUNET_htonll (GNUNET_TIME_absolute_get ().abs_value_us);
ret =
PQexecPrepared (plugin->dbh, "select_expiration_order", 1, paramValues,
paramLengths, paramFormats, 1);
@@ -751,7 +751,7 @@ postgres_plugin_update (void *cls, uint64_t uid, int delta,
PGresult *ret;
int32_t bdelta = (int32_t) htonl ((uint32_t) delta);
uint32_t boid = htonl ((uint32_t) uid);
- uint64_t bexpire = GNUNET_TIME_absolute_hton (expire).abs_value__;
+ uint64_t bexpire = GNUNET_TIME_absolute_hton (expire).abs_value_us__;
const char *paramValues[] = {
(const char *) &bdelta,
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
index e77e8b9fa..9a4b40255 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -488,11 +488,12 @@ sqlite_plugin_put (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
if (size > MAX_ITEM_SIZE)
return GNUNET_SYSERR;
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
- "Storing in database block with type %u/key `%s'/priority %u/expiration in %llu ms (%lld).\n",
+ "Storing in database block with type %u/key `%s'/priority %u/expiration in %s (%s).\n",
type, GNUNET_h2s (key), priority,
(unsigned long long)
- GNUNET_TIME_absolute_get_remaining (expiration).rel_value,
- (long long) expiration.abs_value);
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration),
+ GNUNET_YES),
+ GNUNET_STRINGS_absolute_time_to_string (expiration));
GNUNET_CRYPTO_hash (data, size, &vhash);
stmt = plugin->insertContent;
rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
@@ -500,7 +501,7 @@ sqlite_plugin_put (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
(SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) ||
(SQLITE_OK != sqlite3_bind_int (stmt, 3, priority)) ||
(SQLITE_OK != sqlite3_bind_int (stmt, 4, anonymity)) ||
- (SQLITE_OK != sqlite3_bind_int64 (stmt, 5, expiration.abs_value)) ||
+ (SQLITE_OK != sqlite3_bind_int64 (stmt, 5, expiration.abs_value_us)) ||
(SQLITE_OK != sqlite3_bind_int64 (stmt, 6, rvalue)) ||
(SQLITE_OK !=
sqlite3_bind_blob (stmt, 7, key, sizeof (struct GNUNET_HashCode),
@@ -583,7 +584,7 @@ sqlite_plugin_update (void *cls, uint64_t uid, int delta,
int n;
if ((SQLITE_OK != sqlite3_bind_int (plugin->updPrio, 1, delta)) ||
- (SQLITE_OK != sqlite3_bind_int64 (plugin->updPrio, 2, expire.abs_value))
+ (SQLITE_OK != sqlite3_bind_int64 (plugin->updPrio, 2, expire.abs_value_us))
|| (SQLITE_OK != sqlite3_bind_int64 (plugin->updPrio, 3, uid)))
{
LOG_SQLITE (plugin, msg, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
@@ -655,10 +656,10 @@ execute_get (struct Plugin *plugin, sqlite3_stmt * stmt,
-(size + GNUNET_DATASTORE_ENTRY_OVERHEAD));
break;
}
- expiration.abs_value = sqlite3_column_int64 (stmt, 3);
+ expiration.abs_value_us = sqlite3_column_int64 (stmt, 3);
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
- "Found reply in database with expiration %llu\n",
- (unsigned long long) expiration.abs_value);
+ "Found reply in database with expiration %s\n",
+ GNUNET_STRINGS_absolute_time_to_string (expiration));
ret = proc (proc_cls, sqlite3_column_blob (stmt, 4) /* key */ ,
size, sqlite3_column_blob (stmt, 5) /* data */ ,
sqlite3_column_int (stmt, 0) /* type */ ,
@@ -1040,7 +1041,7 @@ sqlite_plugin_get_expiration (void *cls, PluginDatumProcessor proc,
"Getting random block based on expiration and priority order.\n");
now = GNUNET_TIME_absolute_get ();
stmt = plugin->selExpi;
- if (SQLITE_OK != sqlite3_bind_int64 (stmt, 1, now.abs_value))
+ if (SQLITE_OK != sqlite3_bind_int64 (stmt, 1, now.abs_value_us))
{
LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_bind_XXXX");
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index 66ba416af..a88dd0c20 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -94,7 +94,7 @@ get_expiration (int i)
{
struct GNUNET_TIME_Absolute av;
- av.abs_value = now.abs_value + 20000000 - i * 1000;
+ av.abs_value_us = now.abs_value_us + 20000000000LL - i * 1000 * 1000LL;
return av;
}
@@ -191,20 +191,21 @@ check_value (void *cls, const struct GNUNET_HashCode * key, size_t size,
return;
}
#if 0
- FPRINTF (stderr, "Check value got `%s' of size %u, type %d, expire %llu\n",
+ FPRINTF (stderr,
+ "Check value got `%s' of size %u, type %d, expire %s\n",
GNUNET_h2s (key), (unsigned int) size, type,
- (unsigned long long) expiration.abs_value);
+ GNUNET_STRINGS_absolute_time_to_string (expiration));
FPRINTF (stderr,
- "Check value iteration %d wants size %u, type %d, expire %llu\n", i,
+ "Check value iteration %d wants size %u, type %d, expire %s\n", i,
(unsigned int) get_size (i), get_type (i),
- (unsigned long long) get_expiration (i).abs_value);
+ GNUNET_STRINGS_absolute_time_to_string (get_expiration(i)));
#endif
GNUNET_assert (size == get_size (i));
GNUNET_assert (0 == memcmp (data, get_data (i), size));
GNUNET_assert (type == get_type (i));
GNUNET_assert (priority == get_priority (i));
GNUNET_assert (anonymity == get_anonymity (i));
- GNUNET_assert (expiration.abs_value == get_expiration (i).abs_value);
+ GNUNET_assert (expiration.abs_value_us == get_expiration (i).abs_value_us);
crc->offset++;
if (crc->i == 0)
{
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c
index 9eae32f4a..8baeeede8 100644
--- a/src/datastore/test_datastore_api_management.c
+++ b/src/datastore/test_datastore_api_management.c
@@ -113,7 +113,7 @@ get_expiration (int i)
{
struct GNUNET_TIME_Absolute av;
- av.abs_value = now.abs_value + i * 1000;
+ av.abs_value_us = now.abs_value_us + i * 1000 * 1000LL;
return av;
}
@@ -159,7 +159,7 @@ check_value (void *cls, const struct GNUNET_HashCode * key, size_t size,
GNUNET_assert (type == get_type (i));
GNUNET_assert (priority == get_priority (i));
GNUNET_assert (anonymity == get_anonymity (i));
- GNUNET_assert (expiration.abs_value == get_expiration (i).abs_value);
+ GNUNET_assert (expiration.abs_value_us == get_expiration (i).abs_value_us);
crc->offset++;
crc->i--;
if (crc->i == 0)
diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c
index adfacef0c..3efd7b4ce 100644
--- a/src/datastore/test_plugin_datastore.c
+++ b/src/datastore/test_plugin_datastore.c
@@ -158,8 +158,9 @@ iterate_one_shot (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
guid = uid;
crc->phase++;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Found result type=%u, priority=%u, size=%u, expire=%llu, key %s\n",
- type, priority, size, (unsigned long long) expiration.abs_value,
+ "Found result type=%u, priority=%u, size=%u, expire=%s, key %s\n",
+ type, priority, size,
+ GNUNET_STRINGS_absolute_time_to_string (expiration),
GNUNET_h2s (key));
GNUNET_SCHEDULER_add_now (&test, crc);
return GNUNET_OK;
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c
index e15893bed..70b1500cc 100644
--- a/src/dht/gnunet-service-dht_clients.c
+++ b/src/dht/gnunet-service-dht_clients.c
@@ -461,11 +461,11 @@ transmit_next_request_task (void *cls,
{
cqr->hnode = NULL;
delay = GNUNET_TIME_absolute_get_remaining (cqr->retry_time);
- if (delay.rel_value > 0)
+ if (delay.rel_value_us > 0)
{
cqr->hnode =
GNUNET_CONTAINER_heap_insert (retry_heap, cqr,
- cqr->retry_time.abs_value);
+ cqr->retry_time.abs_value_us);
retry_task =
GNUNET_SCHEDULER_add_delayed (delay, &transmit_next_request_task,
NULL);
@@ -474,7 +474,7 @@ transmit_next_request_task (void *cls,
transmit_request (cqr);
cqr->hnode =
GNUNET_CONTAINER_heap_insert (retry_heap, cqr,
- cqr->retry_time.abs_value);
+ cqr->retry_time.abs_value_us);
}
}
diff --git a/src/dht/gnunet-service-dht_hello.c b/src/dht/gnunet-service-dht_hello.c
index 32a99203f..2ce7f1925 100644
--- a/src/dht/gnunet-service-dht_hello.c
+++ b/src/dht/gnunet-service-dht_hello.c
@@ -76,7 +76,7 @@ process_hello (void *cls, const struct GNUNET_PeerIdentity *peer,
if (hello == NULL)
return;
ex = GNUNET_HELLO_get_last_expiration (hello);
- if (GNUNET_TIME_absolute_get_remaining (ex).rel_value == 0)
+ if (0 == GNUNET_TIME_absolute_get_remaining (ex).rel_value_us)
return;
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# HELLOs obtained from peerinfo"), 1,
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 16955629c..3041cccfe 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.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
@@ -602,10 +602,10 @@ send_find_peer_message (void *cls,
GNUNET_CONTAINER_bloomfilter_free (peer_bf);
GNUNET_CONTAINER_bloomfilter_free (bcc.bloom);
/* schedule next round */
- next_send_time.rel_value =
- DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value +
+ next_send_time.rel_value_us =
+ DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value_us +
GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
- DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value /
+ DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value_us /
(newly_found_peers + 1));
newly_found_peers = 0;
find_peer_task =
@@ -757,7 +757,7 @@ core_transmit_notify (void *cls, size_t size, void *buf)
peer->th = NULL;
while ((NULL != (pending = peer->head)) &&
- (GNUNET_TIME_absolute_get_remaining (pending->timeout).rel_value == 0))
+ (0 == GNUNET_TIME_absolute_get_remaining (pending->timeout).rel_value_us))
{
peer->pending_count--;
GNUNET_CONTAINER_DLL_remove (peer->head, peer->tail, pending);
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c
index efcdf0e14..8889de4fb 100644
--- a/src/dht/gnunet-service-dht_routing.c
+++ b/src/dht/gnunet-service-dht_routing.c
@@ -421,7 +421,7 @@ GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender,
}
recent_req->heap_node =
GNUNET_CONTAINER_heap_insert (recent_heap, recent_req,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
GNUNET_CONTAINER_multihashmap_put (recent_map, key, recent_req,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
diff --git a/src/dns/dnsparser.c b/src/dns/dnsparser.c
index 6ddfebb11..18ef4c219 100644
--- a/src/dns/dnsparser.c
+++ b/src/dns/dnsparser.c
@@ -891,7 +891,7 @@ add_record (char *dst,
}
rl.type = htons (record->type);
rl.class = htons (record->class);
- rl.ttl = htonl (GNUNET_TIME_absolute_get_remaining (record->expiration_time).rel_value / 1000); /* in seconds */
+ rl.ttl = htonl (GNUNET_TIME_absolute_get_remaining (record->expiration_time).rel_value_us / 1000LL / 1000LL); /* in seconds */
rl.data_len = htons ((uint16_t) (pos - (*off + sizeof (struct record_line))));
memcpy (&dst[*off], &rl, sizeof (struct record_line));
*off = pos;
diff --git a/src/dns/dnsstub.c b/src/dns/dnsstub.c
index 3b30d3e63..0e130a77f 100644
--- a/src/dns/dnsstub.c
+++ b/src/dns/dnsstub.c
@@ -447,7 +447,7 @@ do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs,
(0 != memcmp (&rs->addr,
&addr,
addrlen)) ||
- (0 == GNUNET_TIME_absolute_get_remaining (rs->timeout).rel_value) )
+ (0 == GNUNET_TIME_absolute_get_remaining (rs->timeout).rel_value_us) )
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Request timeout or invalid sender address; ignoring reply\n");
diff --git a/src/dns/gnunet-dns-monitor.c b/src/dns/gnunet-dns-monitor.c
index 747a87556..ece96db71 100644
--- a/src/dns/gnunet-dns-monitor.c
+++ b/src/dns/gnunet-dns-monitor.c
@@ -214,7 +214,7 @@ display_record (const struct GNUNET_DNSPARSER_Record *record)
get_type (record->type),
record->name,
format,
- (unsigned int) (GNUNET_TIME_absolute_get_remaining (record->expiration_time).rel_value / 1000));
+ (unsigned int) (GNUNET_TIME_absolute_get_remaining (record->expiration_time).rel_value_us / 1000LL / 1000LL));
GNUNET_free_non_null (tmp);
}
diff --git a/src/dns/plugin_block_dns.c b/src/dns/plugin_block_dns.c
index d8f3cbb6f..58301e095 100644
--- a/src/dns/plugin_block_dns.c
+++ b/src/dns/plugin_block_dns.c
@@ -87,7 +87,7 @@ block_plugin_dns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
if (0 ==
GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh
- (rec->expiration_time)).rel_value)
+ (rec->expiration_time)).rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DNS-Block is invalid: Timeout\n");
return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 358e07434..4e15f3db4 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -674,7 +674,7 @@ get_redirect_state (int af,
if (NULL == state_key)
GNUNET_CONTAINER_heap_update_cost (connections_heap,
state->specifics.tcp_udp.heap_node,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
return state;
}
@@ -1497,7 +1497,7 @@ setup_state_record (struct TunnelState *state)
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
state->specifics.tcp_udp.heap_node = GNUNET_CONTAINER_heap_insert (connections_heap,
state,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
while (GNUNET_CONTAINER_heap_get_size (connections_heap) > max_connections)
{
s = GNUNET_CONTAINER_heap_remove_root (connections_heap);
diff --git a/src/experimentation/gnunet-daemon-experimentation_experiments.c b/src/experimentation/gnunet-daemon-experimentation_experiments.c
index 99348a2cb..891865b39 100644
--- a/src/experimentation/gnunet-daemon-experimentation_experiments.c
+++ b/src/experimentation/gnunet-daemon-experimentation_experiments.c
@@ -158,7 +158,7 @@ find_it (void *cls,
if (0 != strcmp(e->name, find_ctx->name))
return GNUNET_OK;
- if (e->version.abs_value != find_ctx->version.abs_value)
+ if (e->version.abs_value_us != find_ctx->version.abs_value_us)
return GNUNET_OK;
find_ctx->res = e;
@@ -272,8 +272,8 @@ int GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i,
e->name,
GNUNET_STRINGS_absolute_time_to_string (start),
GNUNET_STRINGS_absolute_time_to_string (stop),
- (long long unsigned int) frequency.rel_value / 1000,
- (long long unsigned int) duration.rel_value / 1000);
+ (long long unsigned int) frequency.rel_value_us / 1000000LL,
+ (long long unsigned int) duration.rel_value_us / 1000000LL);
GNUNET_CONTAINER_multihashmap_put (experiments, &e->issuer.hashPubKey, e, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
GNUNET_STATISTICS_set (GED_stats, "# experiments", GNUNET_CONTAINER_multihashmap_size (experiments), GNUNET_NO);
@@ -336,7 +336,7 @@ void exp_file_iterator (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Version missing or invalid \n"), name);
return;
}
- version.abs_value = number;
+ version.abs_value_us = number; // FIXME: what is this supposed to be? Version != TIME!???
/* Required capabilities */
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "CAPABILITIES", &number))
@@ -358,14 +358,14 @@ void exp_file_iterator (void *cls,
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "START", (long long unsigned int *) &start.abs_value))
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "START", (long long unsigned int *) &start.abs_value_us))
start = GNUNET_TIME_UNIT_ZERO_ABS;
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (exp, name, "FREQUENCY", &frequency))
frequency = EXP_DEFAULT_EXP_FREQ;
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (exp, name, "DURATION", &duration))
duration = EXP_DEFAULT_EXP_DUR;
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "STOP", (long long unsigned int *)&stop.abs_value))
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "STOP", (long long unsigned int *)&stop.abs_value_us))
stop = GNUNET_TIME_UNIT_FOREVER_ABS;
GNUNET_EXPERIMENTATION_experiments_add (i, name, issuer, version,
diff --git a/src/experimentation/gnunet-daemon-experimentation_scheduler.c b/src/experimentation/gnunet-daemon-experimentation_scheduler.c
index 784baa4d4..34142fabb 100644
--- a/src/experimentation/gnunet-daemon-experimentation_scheduler.c
+++ b/src/experimentation/gnunet-daemon-experimentation_scheduler.c
@@ -133,7 +133,7 @@ static void run_experiment_inbound (void *cls,const struct GNUNET_SCHEDULER_Task
se->state = REQUESTED;
/* Schedule to run */
start = GNUNET_TIME_absolute_get_remaining(se->e->start);
- if (0 == start.rel_value)
+ if (0 == start.rel_value_us)
se->task = GNUNET_SCHEDULER_add_now (&run_experiment_inbound, se);
else
se->task = GNUNET_SCHEDULER_add_delayed (start, &run_experiment_inbound, se);
@@ -155,7 +155,7 @@ static void run_experiment_inbound (void *cls,const struct GNUNET_SCHEDULER_Task
/* Reschedule */
end = GNUNET_TIME_absolute_get_remaining(GNUNET_TIME_absolute_add (se->e->stop, se->e->frequency));
- if (0 == end.rel_value)
+ if (0 == end.rel_value_us)
{
se->state = STOPPED;
return; /* End of experiment is reached */
@@ -201,7 +201,7 @@ static void run_experiment_outbound (void *cls,const struct GNUNET_SCHEDULER_Tas
/* Reschedule */
end = GNUNET_TIME_absolute_get_remaining(GNUNET_TIME_absolute_add (se->e->stop, se->e->frequency));
- if (0 == end.rel_value)
+ if (0 == end.rel_value_us)
{
se->state = STOPPED;
return; /* End of experiment is reached */
@@ -328,7 +328,7 @@ GED_scheduler_add (struct Node *n, struct Experiment *e, int outbound)
start = GNUNET_TIME_absolute_get_remaining(e->start);
end = GNUNET_TIME_absolute_get_remaining(e->stop);
- if (0 == end.rel_value)
+ if (0 == end.rel_value_us)
return; /* End of experiment is reached */
/* Add additional checks here if required */
@@ -340,7 +340,7 @@ GED_scheduler_add (struct Node *n, struct Experiment *e, int outbound)
if (GNUNET_YES == outbound)
{
- if (0 == start.rel_value)
+ if (0 == start.rel_value_us)
se->task = GNUNET_SCHEDULER_add_now (&run_experiment_outbound, se);
else
se->task = GNUNET_SCHEDULER_add_delayed (start, &run_experiment_outbound, se);
@@ -348,7 +348,7 @@ GED_scheduler_add (struct Node *n, struct Experiment *e, int outbound)
}
else
{
- if (0 == start.rel_value)
+ if (0 == start.rel_value_us)
se->task = GNUNET_SCHEDULER_add_now (&run_experiment_inbound, se);
else
se->task = GNUNET_SCHEDULER_add_delayed (start, &run_experiment_inbound, se);
diff --git a/src/fragmentation/defragmentation.c b/src/fragmentation/defragmentation.c
index 2d3f4a57b..f42207046 100644
--- a/src/fragmentation/defragmentation.c
+++ b/src/fragmentation/defragmentation.c
@@ -354,13 +354,13 @@ estimate_latency (struct MessageContext *mc)
for (i = 0; i < total; i++)
{
x[i] = (double) i;
- y[i] = (double) (first[i].time.abs_value - first[0].time.abs_value);
+ y[i] = (double) (first[i].time.abs_value_us - first[0].time.abs_value_us);
}
gsl_fit_mul (x, 1, y, 1, total, &c1, &cov11, &sumsq);
c1 += sqrt (sumsq); /* add 1 std dev */
- ret.rel_value = (uint64_t) c1;
- if (ret.rel_value == 0)
- ret = GNUNET_TIME_UNIT_MILLISECONDS; /* always at least 1 */
+ ret.rel_value_us = (uint64_t) c1;
+ if (0 == ret.rel_value_us)
+ ret = GNUNET_TIME_UNIT_MICROSECONDS; /* always at least 1 */
return ret;
}
@@ -381,7 +381,7 @@ discard_oldest_mc (struct GNUNET_DEFRAGMENT_Context *dc)
while (NULL != pos)
{
if ((old == NULL) ||
- (old->last_update.abs_value > pos->last_update.abs_value))
+ (old->last_update.abs_value_us > pos->last_update.abs_value_us))
old = pos;
pos = pos->next;
}
diff --git a/src/fragmentation/fragmentation.c b/src/fragmentation/fragmentation.c
index f859b32c7..39a5af814 100644
--- a/src/fragmentation/fragmentation.c
+++ b/src/fragmentation/fragmentation.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- (C) 2009, 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
@@ -180,7 +180,7 @@ transmit_next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
delay = GNUNET_BANDWIDTH_tracker_get_delay (fc->tracker, fsize);
else
delay = GNUNET_TIME_UNIT_ZERO;
- if (delay.rel_value > 0)
+ if (delay.rel_value_us > 0)
{
fc->task = GNUNET_SCHEDULER_add_delayed (delay, &transmit_next, fc);
return;
@@ -207,7 +207,7 @@ transmit_next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_BANDWIDTH_tracker_consume (fc->tracker, fsize);
GNUNET_STATISTICS_update (fc->stats, _("# fragments transmitted"), 1,
GNUNET_NO);
- if (0 != fc->last_round.abs_value)
+ if (0 != fc->last_round.abs_value_us)
GNUNET_STATISTICS_update (fc->stats, _("# fragments retransmitted"), 1,
GNUNET_NO);
@@ -367,8 +367,8 @@ GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc,
/* normal ACK, can update running average of delay... */
fc->wack = GNUNET_NO;
ndelay = GNUNET_TIME_absolute_get_duration (fc->last_round);
- fc->ack_delay.rel_value =
- (ndelay.rel_value / fc->num_transmissions + 3 * fc->ack_delay.rel_value) / 4;
+ fc->ack_delay.rel_value_us =
+ (ndelay.rel_value_us / fc->num_transmissions + 3 * fc->ack_delay.rel_value_us) / 4;
fc->num_transmissions = 0;
/* calculate ratio msg sent vs. msg acked */
ack_cnt = 0;
@@ -392,11 +392,11 @@ GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc,
{
/* some loss, slow down proportionally */
fprintf (stderr, "Prop loss\n");
- fc->msg_delay.rel_value = ((fc->msg_delay.rel_value * ack_cnt) / snd_cnt);
+ fc->msg_delay.rel_value_us = ((fc->msg_delay.rel_value_us * ack_cnt) / snd_cnt);
}
- else if (1 < fc->msg_delay.rel_value)
+ else if (100 < fc->msg_delay.rel_value_us)
{
- fc->msg_delay.rel_value--; /* try a bit faster */
+ fc->msg_delay.rel_value_us -= 100; /* try a bit faster */
}
fc->msg_delay = GNUNET_TIME_relative_min (fc->msg_delay,
GNUNET_TIME_UNIT_SECONDS);
diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c
index 9676f2e3c..91c568554 100644
--- a/src/fs/fs_api.c
+++ b/src/fs/fs_api.c
@@ -164,7 +164,7 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
run_time = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2);
end_time = GNUNET_TIME_absolute_add (qe->start_time, run_time);
rst = GNUNET_TIME_absolute_get_remaining (end_time);
- if (0 == rst.rel_value)
+ if (0 == rst.rel_value_us)
{
num_probes_expired++;
stop_job (qe);
@@ -181,7 +181,7 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
qe->blocks * qe->start_times);
end_time = GNUNET_TIME_absolute_add (qe->start_time, run_time);
rst = GNUNET_TIME_absolute_get_remaining (end_time);
- if (0 == rst.rel_value)
+ if (0 == rst.rel_value_us)
{
num_downloads_expired++;
stop_job (qe);
@@ -781,7 +781,7 @@ write_start_time (struct GNUNET_BIO_WriteHandle *wh,
struct GNUNET_TIME_Relative dur;
dur = GNUNET_TIME_absolute_get_duration (timestamp);
- return GNUNET_BIO_write_int64 (wh, dur.rel_value);
+ return GNUNET_BIO_write_int64 (wh, dur.rel_value_us);
}
@@ -805,7 +805,7 @@ read_start_time (struct GNUNET_BIO_ReadHandle *rh,
{
struct GNUNET_TIME_Relative dur;
- if (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dur.rel_value))
+ if (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dur.rel_value_us))
return GNUNET_SYSERR;
*timestamp = GNUNET_TIME_absolute_subtract (GNUNET_TIME_absolute_get (), dur);
return GNUNET_OK;
@@ -871,7 +871,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, const char *fn,
|| (GNUNET_OK !=
GNUNET_BIO_read_string (rh, "fn", &ret->filename, 16 * 1024)) ||
(GNUNET_OK !=
- GNUNET_BIO_read_int64 (rh, &ret->bo.expiration_time.abs_value)) ||
+ GNUNET_BIO_read_int64 (rh, &ret->bo.expiration_time.abs_value_us)) ||
(GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.anonymity_level)) ||
(GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.content_priority)) ||
(GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.replication_level)))
@@ -1273,7 +1273,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi)
(GNUNET_OK != GNUNET_BIO_write_string (wh, fi->emsg)) ||
(GNUNET_OK != GNUNET_BIO_write_string (wh, fi->filename)) ||
(GNUNET_OK !=
- GNUNET_BIO_write_int64 (wh, fi->bo.expiration_time.abs_value)) ||
+ GNUNET_BIO_write_int64 (wh, fi->bo.expiration_time.abs_value_us)) ||
(GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->bo.anonymity_level)) ||
(GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->bo.content_priority)) ||
(GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->bo.replication_level)))
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 2371e6544..a86df253a 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -1082,7 +1082,7 @@ process_result_with_request (void *cls, const struct GNUNET_HashCode * key,
pi.value.download.specifics.progress.depth = dr->depth;
pi.value.download.specifics.progress.respect_offered = prc->respect_offered;
pi.value.download.specifics.progress.num_transmissions = prc->num_transmissions;
- if (prc->last_transmission.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
+ if (prc->last_transmission.abs_value_us != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
pi.value.download.specifics.progress.block_download_duration
= GNUNET_TIME_absolute_get_duration (prc->last_transmission);
else
@@ -1437,7 +1437,7 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc)
dc->in_receive = GNUNET_NO;
dc->client = NULL;
}
- if (0 == dc->reconnect_backoff.rel_value)
+ if (0 == dc->reconnect_backoff.rel_value_us)
dc->reconnect_backoff = GNUNET_TIME_UNIT_MILLISECONDS;
else
dc->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (dc->reconnect_backoff);
diff --git a/src/fs/fs_misc.c b/src/fs/fs_misc.c
index 89dc48683..ee24fa250 100644
--- a/src/fs/fs_misc.c
+++ b/src/fs/fs_misc.c
@@ -202,7 +202,7 @@ GNUNET_FS_year_to_time (unsigned int year)
t.tm_yday = 1;
tp = mktime (&t);
GNUNET_break (tp != (time_t) - 1);
- ret.abs_value = tp * 1000LL; /* seconds to ms */
+ ret.abs_value_us = tp * 1000LL * 1000LL; /* seconds to microseconds */
return ret;
}
@@ -219,7 +219,7 @@ GNUNET_FS_time_to_year (struct GNUNET_TIME_Absolute at)
struct tm *t;
time_t tp;
- tp = at.abs_value / 1000; /* ms to seconds */
+ tp = at.abs_value_us / 1000LL / 1000LL; /* microseconds to seconds */
t = gmtime (&tp);
if (t == NULL)
return 0;
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index 9bc254254..38bd55caa 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -342,7 +342,7 @@ GNUNET_FS_search_probe_progress_ (void *cls,
{
/* should only happen if the cancel task was already
created on 'DOWNLOAD_INACTIVE' as we were out of time */
- GNUNET_break (0 == sr->remaining_probe_time.rel_value);
+ GNUNET_break (0 == sr->remaining_probe_time.rel_value_us);
}
break;
case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:
@@ -354,7 +354,7 @@ GNUNET_FS_search_probe_progress_ (void *cls,
dur = GNUNET_TIME_absolute_get_duration (sr->probe_active_time);
sr->remaining_probe_time =
GNUNET_TIME_relative_subtract (sr->remaining_probe_time, dur);
- if (0 == sr->remaining_probe_time.rel_value)
+ if (0 == sr->remaining_probe_time.rel_value_us)
sr->probe_cancel_task =
GNUNET_SCHEDULER_add_now (&probe_failure_handler, sr);
GNUNET_FS_search_result_sync_ (sr);
@@ -843,7 +843,7 @@ process_result (struct GNUNET_FS_SearchContext *sc,
const void *data,
size_t size)
{
- if (GNUNET_TIME_absolute_get_duration (expiration).rel_value > 0)
+ if (GNUNET_TIME_absolute_get_duration (expiration).rel_value_us > 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Result received has already expired.\n");
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index e0bdc7ed6..6724dc625 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -638,7 +638,7 @@ uri_loc_parse (const char *s, char **emsg)
}
ass.purpose.size = htonl (sizeof (struct LocUriAssembly));
ass.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT);
- et.abs_value = exptime;
+ et.abs_value_us = exptime * 1000LL * 1000LL;
ass.exptime = GNUNET_TIME_absolute_hton (et);
if (GNUNET_OK !=
GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT,
@@ -2030,13 +2030,14 @@ uri_loc_to_string (const struct GNUNET_FS_Uri *uri)
peerSig =
bin2enc (&uri->data.loc.contentSignature,
sizeof (struct GNUNET_CRYPTO_EccSignature));
- GNUNET_asprintf (&ret, "%s%s%s.%s.%llu.%s.%s.%llu", GNUNET_FS_URI_PREFIX,
+ GNUNET_asprintf (&ret,
+ "%s%s%s.%s.%llu.%s.%s.%llu", GNUNET_FS_URI_PREFIX,
GNUNET_FS_URI_LOC_INFIX, (const char *) &keyhash,
(const char *) &queryhash,
(unsigned long long) GNUNET_ntohll (uri->data.loc.
fi.file_length), peerId,
peerSig,
- (unsigned long long) uri->data.loc.expirationTime.abs_value);
+ (unsigned long long) uri->data.loc.expirationTime.abs_value_us / 1000LL / 1000LL);
GNUNET_free (peerSig);
GNUNET_free (peerId);
return ret;
diff --git a/src/fs/gnunet-daemon-fsprofiler.c b/src/fs/gnunet-daemon-fsprofiler.c
index 16a74b8a0..30a127559 100644
--- a/src/fs/gnunet-daemon-fsprofiler.c
+++ b/src/fs/gnunet-daemon-fsprofiler.c
@@ -189,7 +189,7 @@ parse_pattern (struct Pattern **head,
p = GNUNET_malloc (sizeof (struct Pattern));
p->x = x;
p->y = y;
- p->delay.rel_value = (uint64_t) t;
+ p->delay.rel_value_us = (uint64_t) t;
GNUNET_CONTAINER_DLL_insert (*head, *tail, p);
pattern = strstr (pattern, ")");
GNUNET_assert (NULL != pattern);
@@ -397,7 +397,7 @@ progress_cb (void *cls,
p = info->value.publish.cctx;
GNUNET_STATISTICS_update (stats_handle,
"# publishing time (ms)",
- (long long) GNUNET_TIME_absolute_get_duration (p->start_time).rel_value,
+ (long long) GNUNET_TIME_absolute_get_duration (p->start_time).rel_value_us / 1000LL,
GNUNET_NO);
p->task = GNUNET_SCHEDULER_add_now (&publish_stop_task, p);
return p;
@@ -425,8 +425,9 @@ progress_cb (void *cls,
p = info->value.download.cctx;
GNUNET_STATISTICS_update (stats_handle,
"# download time (ms)",
- (long long) GNUNET_TIME_absolute_get_duration (p->start_time).rel_value,
- GNUNET_NO); p->task = GNUNET_SCHEDULER_add_now (&download_stop_task, p);
+ (long long) GNUNET_TIME_absolute_get_duration (p->start_time).rel_value_us / 1000LL,
+ GNUNET_NO);
+ p->task = GNUNET_SCHEDULER_add_now (&download_stop_task, p);
return p;
case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
p = info->value.download.cctx;
@@ -450,7 +451,7 @@ progress_cb (void *cls,
return NULL; /* not what we want */
GNUNET_STATISTICS_update (stats_handle,
"# search time (ms)",
- (long long) GNUNET_TIME_absolute_get_duration (p->start_time).rel_value,
+ (long long) GNUNET_TIME_absolute_get_duration (p->start_time).rel_value_us / 1000LL,
GNUNET_NO);
p->start_time = GNUNET_TIME_absolute_get ();
p->ctx = GNUNET_FS_download_start (fs_handle, uri,
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
index 04edc66c8..30081f0b4 100644
--- a/src/fs/gnunet-download.c
+++ b/src/fs/gnunet-download.c
@@ -142,8 +142,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
{
s = GNUNET_strdup (GNUNET_STRINGS_relative_time_to_string (info->value.download.eta,
GNUNET_YES));
- if (info->value.download.specifics.progress.block_download_duration.rel_value
- == GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
+ if (info->value.download.specifics.progress.block_download_duration.rel_value_us
+ == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
s2 = _("<unknown time>");
else
s2 = GNUNET_STRINGS_relative_time_to_string (
@@ -152,7 +152,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
t = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed *
1000LL /
(info->value.download.
- duration.rel_value + 1));
+ duration.rel_value_us + 1));
FPRINTF (stdout,
_("Downloading `%s' at %llu/%llu (%s remaining, %s/s). Block took %s to download\n"),
info->value.download.filename,
@@ -183,7 +183,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
s = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * 1000 /
(info->value.download.
- duration.rel_value + 1));
+ duration.rel_value_us + 1));
#if !WINDOWS
if (0 != isatty (1))
fprintf (stdout, "\n");
diff --git a/src/fs/gnunet-fs-profiler.c b/src/fs/gnunet-fs-profiler.c
index 9bc3ff253..cde70ae88 100644
--- a/src/fs/gnunet-fs-profiler.c
+++ b/src/fs/gnunet-fs-profiler.c
@@ -145,7 +145,7 @@ test_master (void *cls, unsigned int num_peers,
// FIXME: enable clients to signal 'completion' before timeout;
// in that case, run the 'terminate_task' "immediately"
- if (0 != timeout.rel_value)
+ if (0 != timeout.rel_value_us)
terminate_taskid = GNUNET_SCHEDULER_add_delayed (timeout,
&terminate_task, NULL);
else
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c
index e90b761d7..df544c21b 100644
--- a/src/fs/gnunet-search.c
+++ b/src/fs/gnunet-search.c
@@ -259,7 +259,7 @@ run (void *cls, char *const *args, const char *cfgfile,
ret = 1;
return;
}
- if (0 != timeout.rel_value)
+ if (0 != timeout.rel_value_us)
GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_task, NULL);
else
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 9074f053e..a8fbda84b 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -202,7 +202,7 @@ GSF_update_datastore_delay_ (struct GNUNET_TIME_Absolute start)
struct GNUNET_TIME_Relative delay;
delay = GNUNET_TIME_absolute_get_duration (start);
- GNUNET_LOAD_update (datastore_get_load, delay.rel_value);
+ GNUNET_LOAD_update (datastore_get_load, delay.rel_value_us);
}
@@ -260,16 +260,16 @@ update_latencies (void *cls,
{
if (GNUNET_ATS_QUALITY_NET_DELAY != ntohl (ats[i].type))
continue;
- latency.rel_value = ntohl (ats[i].value);
+ latency.rel_value_us = ntohl (ats[i].value);
GSF_update_peer_latency_ (&address->peer,
latency);
- GSF_avg_latency.rel_value =
- (GSF_avg_latency.rel_value * 31 +
+ GSF_avg_latency.rel_value_us =
+ (GSF_avg_latency.rel_value_us * 31 +
GNUNET_MIN (5000, ntohl (ats[i].value))) / 32;
GNUNET_STATISTICS_set (GSF_stats,
gettext_noop
("# running average P2P latency (ms)"),
- GSF_avg_latency.rel_value, GNUNET_NO);
+ GSF_avg_latency.rel_value_us / 1000LL, GNUNET_NO);
break;
}
}
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index e1a3e1ac9..5f047665e 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -488,7 +488,7 @@ peer_transmit_ready_cb (void *cls, size_t size, void *buf)
}
GNUNET_LOAD_update (cp->ppd.transmission_delay,
GNUNET_TIME_absolute_get_duration
- (pth->transmission_request_start_time).rel_value);
+ (pth->transmission_request_start_time).rel_value_us);
ret = pth->gmc (pth->gmc_cls, size, buf);
if (NULL != (pos = cp->pth_head))
{
@@ -621,7 +621,7 @@ revive_migration (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
cp->mig_revive_task = GNUNET_SCHEDULER_NO_TASK;
bt = GNUNET_TIME_absolute_get_remaining (cp->ppd.migration_blocked_until);
- if (0 != bt.rel_value)
+ if (0 != bt.rel_value_us)
{
/* still time left... */
cp->mig_revive_task =
@@ -833,12 +833,12 @@ get_randomized_delay ()
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
GNUNET_CRYPTO_random_u32
(GNUNET_CRYPTO_QUALITY_WEAK,
- 2 * GSF_avg_latency.rel_value + 1));
+ 2 * GSF_avg_latency.rel_value_us + 1));
#if INSANE_STATISTICS
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop
("# artificial delays introduced (ms)"),
- ret.rel_value, GNUNET_NO);
+ ret.rel_value_us / 1000LL, GNUNET_NO);
#endif
return ret;
}
@@ -1216,7 +1216,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
spid = 0;
if ((GNUNET_LOAD_get_load (cp->ppd.transmission_delay) > 3 * (1 + priority))
|| (GNUNET_LOAD_get_average (cp->ppd.transmission_delay) >
- GNUNET_CONSTANTS_MAX_CORK_DELAY.rel_value * 2 +
+ GNUNET_CONSTANTS_MAX_CORK_DELAY.rel_value_us * 2 +
GNUNET_LOAD_get_average (GSF_rt_entry_lifetime)))
{
/* don't have BW to send to peer, or would likely take longer than we have for it,
@@ -1253,7 +1253,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
prd = GSF_pending_request_get_data_ (pr);
if (prd->type == type)
{
- if (prd->ttl.abs_value >= GNUNET_TIME_absolute_get ().abs_value + ttl)
+ if (prd->ttl.abs_value_us >= GNUNET_TIME_absolute_get ().abs_value_us + ttl * 1000LL)
{
/* existing request has higher TTL, drop new one! */
prd->priority += priority;
@@ -1425,9 +1425,9 @@ GSF_peer_update_performance_ (struct GSF_ConnectedPeer *cp,
struct GNUNET_TIME_Relative delay;
delay = GNUNET_TIME_absolute_get_duration (request_time);
- cp->ppd.avg_reply_delay.rel_value =
- (cp->ppd.avg_reply_delay.rel_value * (RUNAVG_DELAY_N - 1) +
- delay.rel_value) / RUNAVG_DELAY_N;
+ cp->ppd.avg_reply_delay.rel_value_us =
+ (cp->ppd.avg_reply_delay.rel_value_us * (RUNAVG_DELAY_N - 1) +
+ delay.rel_value_us) / RUNAVG_DELAY_N;
cp->ppd.avg_priority =
(cp->ppd.avg_priority * (RUNAVG_DELAY_N - 1) +
request_priority) / RUNAVG_DELAY_N;
@@ -1678,7 +1678,7 @@ void
GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp,
struct GNUNET_TIME_Absolute block_time)
{
- if (cp->last_migration_block.abs_value > block_time.abs_value)
+ if (cp->last_migration_block.abs_value_us > block_time.abs_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Migration already blocked for another %s\n",
@@ -1686,8 +1686,9 @@ GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp,
(cp->last_migration_block), GNUNET_YES));
return; /* already blocked */
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking to stop migration for %llu ms\n",
- (unsigned long long) GNUNET_TIME_absolute_get_remaining (block_time).rel_value);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking to stop migration for %s\n",
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (block_time),
+ GNUNET_YES));
cp->last_migration_block = block_time;
if (NULL != cp->migration_pth)
GSF_peer_transmit_cancel_ (cp->migration_pth);
diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c
index 5c63e7b66..21f028a2d 100644
--- a/src/fs/gnunet-service-fs_pe.c
+++ b/src/fs/gnunet-service-fs_pe.c
@@ -283,11 +283,11 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp)
delay =
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
8 + (1LL << 24));
- delay.rel_value =
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- delay.rel_value + 1);
+ delay.rel_value_us =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ delay.rel_value_us + 1);
/* Add 0.01 to avg_delay to avoid division-by-zero later */
- avg_delay = (((avg_delay * (N - 1.0)) + delay.rel_value) / N) + 0.01;
+ avg_delay = (((avg_delay * (N - 1.0)) + delay.rel_value_us) / N) + 0.01;
/*
* For the priority, we need to consider a few basic rules:
@@ -312,27 +312,27 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp)
*/
rp->priority =
round ((GSF_current_priorities +
- 1.0) * atan (delay.rel_value / avg_delay)) / M_PI_4;
+ 1.0) * atan (delay.rel_value_us / avg_delay)) / M_PI_4;
/* Note: usage of 'round' and 'atan' requires -lm */
if (rp->transmission_counter != 0)
- delay.rel_value += TTL_DECREMENT;
+ delay.rel_value_us += TTL_DECREMENT * 1000;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Considering (re)transmission number %u in %llu ms\n",
+ "Considering (re)transmission number %u in %s\n",
(unsigned int) rp->transmission_counter,
- (unsigned long long) delay.rel_value);
+ GNUNET_STRINGS_relative_time_to_string (delay,
+ GNUNET_YES));
rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Earliest (re)transmission for `%s' in %us\n",
GNUNET_h2s (&prd->query), rp->transmission_counter);
GNUNET_assert (rp->hn == NULL);
- if (GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission).rel_value
- == 0)
+ if (0 == GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission).rel_value_us)
rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority);
else
rp->hn =
GNUNET_CONTAINER_heap_insert (pp->delay_heap, rp,
- rp->earliest_transmission.abs_value);
+ rp->earliest_transmission.abs_value_us);
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_contains_value (pp->plan_map,
get_rp_key (rp),
@@ -363,8 +363,8 @@ get_latest (const struct GSF_RequestPlan *rp)
bi = bi->next_PE;
while (NULL != bi)
{
- if (GSF_pending_request_get_data_ (bi->pr)->ttl.abs_value >
- GSF_pending_request_get_data_ (ret)->ttl.abs_value)
+ if (GSF_pending_request_get_data_ (bi->pr)->ttl.abs_value_us >
+ GSF_pending_request_get_data_ (ret)->ttl.abs_value_us)
ret = bi->pr;
bi = bi->next_PE;
}
@@ -459,8 +459,8 @@ schedule_peer_transmission (void *cls,
}
/* move ready requests to priority queue */
while ((NULL != (rp = GNUNET_CONTAINER_heap_peek (pp->delay_heap))) &&
- (GNUNET_TIME_absolute_get_remaining
- (rp->earliest_transmission).rel_value == 0))
+ (0 == GNUNET_TIME_absolute_get_remaining
+ (rp->earliest_transmission).rel_value_us))
{
GNUNET_assert (rp == GNUNET_CONTAINER_heap_remove_root (pp->delay_heap));
rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority);
@@ -477,10 +477,12 @@ schedule_peer_transmission (void *cls,
}
delay = GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sleeping for %llu ms before retrying requests on plan %p.\n",
- (unsigned long long) delay.rel_value, pp);
- GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# delay heap timeout"),
- delay.rel_value, GNUNET_NO);
+ "Sleeping for %s before retrying requests on plan %p.\n",
+ GNUNET_STRINGS_relative_time_to_string (delay,
+ GNUNET_YES),
+ pp);
+ GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# delay heap timeout (ms)"),
+ delay.rel_value_us / 1000LL, GNUNET_NO);
pp->task =
GNUNET_SCHEDULER_add_delayed (delay, &schedule_peer_transmission, pp);
@@ -551,8 +553,8 @@ merge_pr (void *cls, const struct GNUNET_HashCode * query, void *element)
GNUNET_NO);
#endif
latest = get_latest (rp);
- if (GSF_pending_request_get_data_ (latest)->ttl.abs_value <
- prd->ttl.abs_value)
+ if (GSF_pending_request_get_data_ (latest)->ttl.abs_value_us <
+ prd->ttl.abs_value_us)
{
#if INSANE_STATISTICS
GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# requests refreshed"),
@@ -721,7 +723,7 @@ GSF_request_plan_reference_get_last_transmission_ (
{
if (bi->rp->pp->cp == sender)
{
- if (0 == bi->rp->last_transmission.abs_value)
+ if (0 == bi->rp->last_transmission.abs_value_us)
*result = GNUNET_TIME_UNIT_FOREVER_ABS;
else
*result = bi->rp->last_transmission;
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index a78cbf287..627d376ef 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2009, 2010, 2011, 2012 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
@@ -373,7 +373,7 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
{
pr->hnode =
GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap, pr,
- pr->public_data.ttl.abs_value);
+ pr->public_data.ttl.abs_value_us);
/* make sure we don't track too many requests */
while (GNUNET_CONTAINER_heap_get_size (requests_by_expiration_heap) >
max_pending_requests)
@@ -555,8 +555,8 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr,
pr->public_data.respect_offered += prio;
gm->priority = htonl (prio);
now = GNUNET_TIME_absolute_get ();
- ttl = (int64_t) (pr->public_data.ttl.abs_value - now.abs_value);
- gm->ttl = htonl (ttl / 1000);
+ ttl = (int64_t) (pr->public_data.ttl.abs_value_us - now.abs_value_us);
+ gm->ttl = htonl (ttl / 1000LL / 1000LL);
gm->filter_mutator = htonl (pr->mingle);
gm->hash_bitmap = htonl (bm);
gm->query = pr->public_data.query;
@@ -825,12 +825,12 @@ process_reply (void *cls, const struct GNUNET_HashCode * key, void *value)
update_request_performance_data (prq, pr);
GNUNET_LOAD_update (GSF_rt_entry_lifetime,
GNUNET_TIME_absolute_get_duration (pr->
- public_data.start_time).rel_value);
+ public_data.start_time).rel_value_us);
if (GNUNET_YES !=
GSF_request_plan_reference_get_last_transmission_ (pr->public_data.pr_head,
prq->sender,
&last_transmission))
- last_transmission.abs_value = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value;
+ last_transmission.abs_value_us = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
/* pass on to other peers / local clients */
pr->rh (pr->rh_cls, prq->eval, pr, prq->anonymity_level, prq->expiration,
last_transmission, prq->type, prq->data, prq->size);
@@ -891,7 +891,7 @@ process_reply (void *cls, const struct GNUNET_HashCode * key, void *value)
if (! GSF_request_plan_reference_get_last_transmission_ (pr->public_data.pr_head,
prq->sender,
&last_transmission))
- last_transmission.abs_value = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value;
+ last_transmission.abs_value_us = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
pr->rh (pr->rh_cls, prq->eval, pr,
prq->anonymity_level, prq->expiration,
last_transmission, prq->type, prq->data, prq->size);
@@ -947,13 +947,13 @@ put_migration_continuation (void *cls, int success,
if (GNUNET_SYSERR != success)
{
GNUNET_LOAD_update (datastore_put_load,
- GNUNET_TIME_absolute_get_duration (pmc->start).rel_value);
+ GNUNET_TIME_absolute_get_duration (pmc->start).rel_value_us);
}
else
{
/* on queue failure / timeout, increase the put load dramatically */
GNUNET_LOAD_update (datastore_put_load,
- GNUNET_TIME_UNIT_MINUTES.rel_value);
+ GNUNET_TIME_UNIT_MINUTES.rel_value_us);
}
}
cp = GSF_peer_get_ (&pmc->origin);
@@ -962,7 +962,7 @@ put_migration_continuation (void *cls, int success,
if (NULL != cp)
{
ppd = GSF_get_peer_performance_data_ (cp);
- ppd->migration_delay.rel_value /= 2;
+ ppd->migration_delay.rel_value_us /= 2;
}
GNUNET_free (pmc);
return;
@@ -972,7 +972,7 @@ put_migration_continuation (void *cls, int success,
(NULL != cp) )
{
ppd = GSF_get_peer_performance_data_ (cp);
- if (min_expiration.abs_value > 0)
+ if (min_expiration.abs_value_us > 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking to stop migration for %s because datastore is full\n",
@@ -985,8 +985,8 @@ put_migration_continuation (void *cls, int success,
ppd->migration_delay);
ppd->migration_delay = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_HOURS,
ppd->migration_delay);
- mig_pause.rel_value = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
- ppd->migration_delay.rel_value);
+ mig_pause.rel_value_us = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
+ ppd->migration_delay.rel_value_us);
ppd->migration_delay = GNUNET_TIME_relative_multiply (ppd->migration_delay, 2);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Replicated content already exists locally, asking to stop migration for %s\n",
@@ -1711,8 +1711,9 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
(GNUNET_CRYPTO_QUALITY_WEAK,
(unsigned int) (60000 * putl * putl)));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Asking to stop migration for %llu ms because of load %f and events %d/%d\n",
- (unsigned long long) block_time.rel_value,
+ "Asking to stop migration for %s because of load %f and events %d/%d\n",
+ GNUNET_STRINGS_relative_time_to_string (block_time,
+ GNUNET_YES),
putl,
active_to_migration,
(GNUNET_NO == prq.request_found));
diff --git a/src/fs/gnunet-service-fs_push.c b/src/fs/gnunet-service-fs_push.c
index e7fbbdcaf..70c13f49f 100644
--- a/src/fs/gnunet-service-fs_push.c
+++ b/src/fs/gnunet-service-fs_push.c
@@ -482,8 +482,8 @@ process_migration_content (void *cls, const struct GNUNET_HashCode * key, size_t
consider_gathering ();
return;
}
- if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value <
- MIN_MIGRATION_CONTENT_LIFETIME.rel_value)
+ if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us <
+ MIN_MIGRATION_CONTENT_LIFETIME.rel_value_us)
{
/* content will expire soon, don't bother */
consider_gathering ();
diff --git a/src/fs/perf_gnunet_service_fs_p2p.c b/src/fs/perf_gnunet_service_fs_p2p.c
index 3a6b9fd03..b4b71be4e 100644
--- a/src/fs/perf_gnunet_service_fs_p2p.c
+++ b/src/fs/perf_gnunet_service_fs_p2p.c
@@ -254,11 +254,11 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
}
del = GNUNET_TIME_absolute_get_duration (start_time);
- if (del.rel_value == 0)
- del.rel_value = 1;
+ if (del.rel_value_us == 0)
+ del.rel_value_us = 1;
fancy =
GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) *
- 1000LL / del.rel_value);
+ 1000000LL / del.rel_value_us);
FPRINTF (stdout, "Download speed was %s/s\n", fancy);
GNUNET_free (fancy);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n",
diff --git a/src/fs/perf_gnunet_service_fs_p2p_respect.c b/src/fs/perf_gnunet_service_fs_p2p_respect.c
index 35425a253..c5846c8c3 100644
--- a/src/fs/perf_gnunet_service_fs_p2p_respect.c
+++ b/src/fs/perf_gnunet_service_fs_p2p_respect.c
@@ -297,11 +297,11 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
return;
}
del = GNUNET_TIME_absolute_get_duration (start_time);
- if (del.rel_value == 0)
- del.rel_value = 1;
+ if (del.rel_value_us == 0)
+ del.rel_value_us = 1;
fancy =
GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) *
- 1000LL / del.rel_value);
+ 1000000LL / del.rel_value_us);
FPRINTF (stderr, "Download speed of type `%s' was %s/s\n", type, fancy);
GNUNET_free (fancy);
if (NUM_DAEMONS != ++download_counter)
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c
index 519923450..c069875cf 100644
--- a/src/fs/test_fs_download.c
+++ b/src/fs/test_fs_download.c
@@ -142,18 +142,18 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
fprintf (stdout,
"Publishing complete, %llu kb/s.\n",
- (unsigned long long) (FILESIZE * 1000LL /
+ (unsigned long long) (FILESIZE * 1000000LL /
(1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value) / 1024LL));
+ (start).rel_value_us) / 1024LL));
GAUGER ("FS",
(GNUNET_YES == indexed)
? "Publishing speed (indexing)"
: "Publishing speed (insertion)",
- (unsigned long long) (FILESIZE * 1000LL /
+ (unsigned long long) (FILESIZE * 1000000LL /
(1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value) / 1024LL), "kb/s");
+ (start).rel_value_us) / 1024LL), "kb/s");
fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst");
start = GNUNET_TIME_absolute_get ();
download =
@@ -168,18 +168,18 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
fprintf (stdout,
"Download complete, %llu kb/s.\n",
- (unsigned long long) (FILESIZE * 1000LL /
+ (unsigned long long) (FILESIZE * 1000000LL /
(1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value) / 1024LL));
+ (start).rel_value_us) / 1024LL));
GAUGER ("FS",
(GNUNET_YES == indexed)
? "Local download speed (indexed)"
: "Local download speed (inserted)",
- (unsigned long long) (FILESIZE * 1000LL /
+ (unsigned long long) (FILESIZE * 1000000LL /
(1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value) / 1024LL), "kb/s");
+ (start).rel_value_us) / 1024LL), "kb/s");
GNUNET_SCHEDULER_add_now (&abort_download_task, NULL);
break;
case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c
index d5883874d..b380fd4af 100644
--- a/src/fs/test_fs_download_persistence.c
+++ b/src/fs/test_fs_download_persistence.c
@@ -164,10 +164,10 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
break;
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
printf ("Publishing complete, %llu kbps.\n",
- (unsigned long long) (FILESIZE * 1000LL /
+ (unsigned long long) (FILESIZE * 1000000LL /
(1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value) / 1024LL));
+ (start).rel_value_us) / 1024LL));
fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst");
start = GNUNET_TIME_absolute_get ();
GNUNET_assert (download == NULL);
@@ -179,10 +179,10 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
consider_restart (event->status);
printf ("Download complete, %llu kbps.\n",
- (unsigned long long) (FILESIZE * 1000LL /
+ (unsigned long long) (FILESIZE * 1000000LL /
(1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value) / 1024LL));
+ (start).rel_value_us) / 1024LL));
GNUNET_SCHEDULER_add_now (&abort_download_task, NULL);
break;
case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c
index 91dad7ca9..b505e8a18 100644
--- a/src/fs/test_fs_list_indexed.c
+++ b/src/fs/test_fs_list_indexed.c
@@ -95,10 +95,10 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
ret = event->value.publish.cctx;
printf ("Publish complete, %llu kbps.\n",
- (unsigned long long) (FILESIZE * 1000 /
+ (unsigned long long) (FILESIZE * 1000000LL /
(1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value) / 1024));
+ (start).rel_value_us) / 1024));
if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx))
GNUNET_SCHEDULER_add_continuation (&list_indexed_task, NULL,
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c
index e51d6e5d4..7ff9c9202 100644
--- a/src/fs/test_fs_publish.c
+++ b/src/fs/test_fs_publish.c
@@ -82,10 +82,10 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
ret = event->value.publish.cctx;
printf ("Publish complete, %llu kbps.\n",
- (unsigned long long) (FILESIZE * 1000 /
+ (unsigned long long) (FILESIZE * 1000000LL /
(1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value) / 1024));
+ (start).rel_value_us) / 1024));
if (0 == strcmp ("publish-context-dir", event->value.publish.cctx))
GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c
index 577831a28..1dc8c43aa 100644
--- a/src/fs/test_fs_publish_persistence.c
+++ b/src/fs/test_fs_publish_persistence.c
@@ -134,10 +134,10 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
consider_restart (event->status);
ret = event->value.publish.cctx;
printf ("Publish complete, %llu kbps.\n",
- (unsigned long long) (FILESIZE * 1000LL /
+ (unsigned long long) (FILESIZE * 1000000LL /
(1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value) / 1024));
+ (start).rel_value_us) / 1024));
if (0 == strcmp ("publish-context-dir", event->value.publish.cctx))
GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
break;
diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c
index 6b89dcad8..033195f0b 100644
--- a/src/fs/test_fs_unindex.c
+++ b/src/fs/test_fs_unindex.c
@@ -92,20 +92,20 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
break;
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
printf ("Publishing complete, %llu kbps.\n",
- (unsigned long long) (FILESIZE * 1000 /
+ (unsigned long long) (FILESIZE * 1000000LL /
(1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value) / 1024));
+ (start).rel_value_us) / 1024));
start = GNUNET_TIME_absolute_get ();
unindex = GNUNET_FS_unindex_start (fs, fn, "unindex");
GNUNET_assert (unindex != NULL);
break;
case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
printf ("Unindex complete, %llu kbps.\n",
- (unsigned long long) (FILESIZE * 1000 /
+ (unsigned long long) (FILESIZE * 1000000LL /
(1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value) / 1024));
+ (start).rel_value_us) / 1024));
GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c
index b11748e2a..ef143ecef 100644
--- a/src/fs/test_fs_unindex_persistence.c
+++ b/src/fs/test_fs_unindex_persistence.c
@@ -134,20 +134,20 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
break;
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
printf ("Publishing complete, %llu kbps.\n",
- (unsigned long long) (FILESIZE * 1000 /
+ (unsigned long long) (FILESIZE * 1000000LL /
(1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value) / 1024));
+ (start).rel_value_us) / 1024));
start = GNUNET_TIME_absolute_get ();
unindex = GNUNET_FS_unindex_start (fs, fn, "unindex");
GNUNET_assert (unindex != NULL);
break;
case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
printf ("Unindex complete, %llu kbps.\n",
- (unsigned long long) (FILESIZE * 1000 /
+ (unsigned long long) (FILESIZE * 1000000LL /
(1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value) / 1024));
+ (start).rel_value_us) / 1024));
GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c
index 138e35c47..58e6374d5 100644
--- a/src/fs/test_gnunet_service_fs_migration.c
+++ b/src/fs/test_gnunet_service_fs_migration.c
@@ -73,11 +73,11 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
{
del = GNUNET_TIME_absolute_get_duration (start_time);
- if (del.rel_value == 0)
- del.rel_value = 1;
+ if (del.rel_value_us == 0)
+ del.rel_value_us = 1;
fancy =
GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) *
- 1000LL / del.rel_value);
+ 1000000LL / del.rel_value_us);
FPRINTF (stdout, "Download speed was %s/s\n", fancy);
GNUNET_free (fancy);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n",
diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c
index e37a322b8..63f5627c2 100644
--- a/src/fs/test_gnunet_service_fs_p2p.c
+++ b/src/fs/test_gnunet_service_fs_p2p.c
@@ -64,11 +64,11 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
{
del = GNUNET_TIME_absolute_get_duration (start_time);
- if (del.rel_value == 0)
- del.rel_value = 1;
+ if (del.rel_value_us == 0)
+ del.rel_value_us = 1;
fancy =
- GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) *
- 1000LL / del.rel_value);
+ GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) *
+ 1000000LL / del.rel_value_us);
FPRINTF (stdout, "Download speed was %s/s\n", fancy);
GNUNET_free (fancy);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n",
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c
index ec64f0730..c1fdc2dc8 100644
--- a/src/gns/gnunet-dns2gns.c
+++ b/src/gns/gnunet-dns2gns.c
@@ -282,7 +282,7 @@ result_processor (void *cls,
//packet->flags.opcode = GNUNET_DNSPARSER_OPCODE_STATUS; // ???
for (i=0;i<rd_count;i++)
{
- rec.expiration_time.abs_value = rd[i].expiration_time;
+ rec.expiration_time.abs_value_us = rd[i].expiration_time;
switch (rd[i].record_type)
{
case GNUNET_DNSPARSER_TYPE_A:
diff --git a/src/gns/gnunet-gns-fcfsd.c b/src/gns/gnunet-gns-fcfsd.c
index 832060583..dd4572cb1 100644
--- a/src/gns/gnunet-gns-fcfsd.c
+++ b/src/gns/gnunet-gns-fcfsd.c
@@ -804,7 +804,7 @@ run_httpd ()
GNUNET_assert (MHD_YES == MHD_get_fdset (httpd, &rs, &ws, &es, &max));
haveto = MHD_get_timeout (httpd, &timeout);
if (haveto == MHD_YES)
- tv.rel_value = (uint64_t) timeout;
+ tv.rel_value_us = (uint64_t) timeout * 1000LL;
else
tv = GNUNET_TIME_UNIT_FOREVER_REL;
GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1);
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index 4752422dd..46b16c323 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -2200,7 +2200,7 @@ run_httpd (struct MhdHttpList *hd)
haveto = MHD_get_timeout (hd->daemon, &timeout);
if (MHD_YES == haveto)
- tv.rel_value = (uint64_t) timeout;
+ tv.rel_value_us = (uint64_t) timeout * 1000LL;
else
tv = GNUNET_TIME_UNIT_FOREVER_REL;
GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1);
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 8200e3f87..1bff3e51d 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -427,7 +427,7 @@ put_gns_record (void *cls,
GNUNET_STRINGS_relative_time_to_string (put_interval, GNUNET_YES));
GNUNET_STATISTICS_set (statistics,
"Current zone iteration interval (in ms)",
- put_interval.rel_value,
+ put_interval.rel_value_us / 1000LL,
GNUNET_NO);
GNUNET_STATISTICS_update (statistics,
"Number of zone iterations", 1, GNUNET_NO);
@@ -545,7 +545,7 @@ put_gns_record (void *cls,
GNUNET_STATISTICS_set (statistics,
"Current zone iteration interval (ms)",
- next_put_interval.rel_value,
+ next_put_interval.rel_value_us / 1000LL,
GNUNET_NO);
zone_publish_task = GNUNET_SCHEDULER_add_delayed (next_put_interval,
&publish_zone_dht_next,
diff --git a/src/gns/gnunet-service-gns_interceptor.c b/src/gns/gnunet-service-gns_interceptor.c
index affa0f5d6..8f55b8284 100644
--- a/src/gns/gnunet-service-gns_interceptor.c
+++ b/src/gns/gnunet-service-gns_interceptor.c
@@ -141,7 +141,7 @@ reply_to_dns (void* cls, uint32_t rd_count,
answer_records[i].data.raw.data = (char*)rd[i].data;
}
GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
- answer_records[i].expiration_time.abs_value = rd[i].expiration_time;
+ answer_records[i].expiration_time.abs_value_us = rd[i].expiration_time;
answer_records[i].class = GNUNET_DNSPARSER_CLASS_INTERNET;//hmmn
}
else
@@ -168,7 +168,7 @@ reply_to_dns (void* cls, uint32_t rd_count,
additional_records[i].data.raw.data = (char*)rd[i].data;
}
GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
- additional_records[i].expiration_time.abs_value = rd[i].expiration_time;
+ additional_records[i].expiration_time.abs_value_us = rd[i].expiration_time;
additional_records[i].class = GNUNET_DNSPARSER_CLASS_INTERNET;//hmmn
}
}
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 2e96b60ea..bd9daf56e 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -888,8 +888,10 @@ dht_lookup_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
char new_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_REC-%llu: dht lookup for query %s (%llus) timed out.\n",
- rh->id, rh->name, rh->timeout.rel_value);
+ "GNS_PHASE_REC-%llu: dht lookup for query %s (%s) timed out.\n",
+ rh->id, rh->name,
+ GNUNET_STRINGS_relative_time_to_string (rh->timeout,
+ GNUNET_YES));
/**
* Start resolution in bg
*/
@@ -1042,7 +1044,7 @@ process_record_result_dht (void* cls,
namestore_bg_task->node = GNUNET_CONTAINER_heap_insert (ns_task_heap,
namestore_bg_task,
- GNUNET_TIME_absolute_get().abs_value);
+ GNUNET_TIME_absolute_get().abs_value_us);
if (0 < rh->answered)
rh->proc (rh->proc_cls, rh, num_records, rd);
else
@@ -1072,7 +1074,7 @@ resolve_record_dht (struct ResolverHandle *rh)
rh->dht_heap_node = NULL;
- if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value != rh->timeout.rel_value)
+ if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != rh->timeout.rel_value_us)
{
/**
* Update timeout if necessary
@@ -1114,7 +1116,7 @@ resolve_record_dht (struct ResolverHandle *rh)
}
rh->dht_heap_node = GNUNET_CONTAINER_heap_insert (dht_lookup_heap,
rh,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
}
xquery = htonl (rlh->record_type);
@@ -1169,7 +1171,7 @@ process_record_result_ns (void* cls,
if (NULL != name)
{
rh->status |= RSL_RECORD_EXISTS;
- if (remaining_time.rel_value == 0)
+ if (remaining_time.rel_value_us == 0)
rh->status |= RSL_RECORD_EXPIRED;
}
if (0 == rd_count)
@@ -1210,8 +1212,8 @@ process_record_result_ns (void* cls,
//FIXME: eh? do I have to handle this here?
GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
- et.abs_value = rd[i].expiration_time;
- if (0 == (GNUNET_TIME_absolute_get_remaining (et)).rel_value)
+ et.abs_value_us = rd[i].expiration_time;
+ if (0 == (GNUNET_TIME_absolute_get_remaining (et)).rel_value_us)
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"GNS_PHASE_REC-%llu: This record is expired. Skipping\n",
@@ -1554,7 +1556,7 @@ read_dns_response (void *cls,
rd.data_size = packet->answers[i].data.raw.data_len;
rd.record_type = packet->answers[i].type;
rd.flags = 0;
- rd.expiration_time = packet->answers[i].expiration_time.abs_value;
+ rd.expiration_time = packet->answers[i].expiration_time.abs_value_us;
finish_lookup (rh, rlh, 1, &rd);
GNUNET_DNSPARSER_free_packet (packet);
return;
@@ -1931,9 +1933,10 @@ dht_authority_lookup_timeout (void *cls,
char new_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_DELEGATE_DHT-%llu: dht lookup for query %s (%llus) timed out.\n",
+ "GNS_PHASE_DELEGATE_DHT-%llu: dht lookup for query %s (%s) timed out.\n",
rh->id, rh->authority_name,
- rh->timeout.rel_value);
+ GNUNET_STRINGS_relative_time_to_string (rh->timeout,
+ GNUNET_YES));
rh->status |= RSL_TIMED_OUT;
rh->timeout_task = GNUNET_SCHEDULER_NO_TASK;
@@ -2058,13 +2061,13 @@ process_pkey_revocation_result_ns (void *cls,
}
if ((NULL == name) ||
- (0 == remaining_time.rel_value))
+ (0 == remaining_time.rel_value_us))
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"GNS_PHASE_DELEGATE_REV-%llu: + Records don't exist or are expired.\n",
rh->id, name);
- if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value != rh->timeout.rel_value)
+ if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != rh->timeout.rel_value_us)
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"GNS_PHASE_DELEGATE_REV-%llu: Starting background lookup for %s type %d\n",
@@ -2291,7 +2294,7 @@ process_delegation_result_dht (void* cls,
namestore_bg_task->node = GNUNET_CONTAINER_heap_insert (ns_task_heap,
namestore_bg_task,
- GNUNET_TIME_absolute_get().abs_value);
+ GNUNET_TIME_absolute_get().abs_value_us);
namestore_bg_task->qe = GNUNET_NAMESTORE_record_put (namestore_handle,
&nrb->public_key,
name,
@@ -2762,7 +2765,7 @@ resolve_delegation_dht (struct ResolverHandle *rh)
&rh->authority,
&lookup_key);
rh->dht_heap_node = NULL;
- if (rh->timeout.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
+ if (rh->timeout.rel_value_us != GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
{
rh->timeout_cont = &dht_authority_lookup_timeout;
rh->timeout_cont_cls = rh;
@@ -2788,7 +2791,7 @@ resolve_delegation_dht (struct ResolverHandle *rh)
}
rh->dht_heap_node = GNUNET_CONTAINER_heap_insert (dht_lookup_heap,
rh,
- GNUNET_TIME_absolute_get().abs_value);
+ GNUNET_TIME_absolute_get().abs_value_us);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Beginning DHT lookup for %s in zone %s for request %llu\n",
@@ -3096,7 +3099,7 @@ process_delegation_result_ns (void* cls,
GNUNET_short_h2s (&zone));
rh->status |= RSL_RECORD_EXISTS;
- if (0 == remaining_time.rel_value)
+ if (0 == remaining_time.rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"GNS_PHASE_DELEGATE_NS-%llu: Record set %s expired.\n",
@@ -3194,13 +3197,13 @@ process_delegation_result_ns (void* cls,
continue;
}
GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
- et.abs_value = rd[i].expiration_time;
- if (0 == (GNUNET_TIME_absolute_get_remaining (et)).rel_value)
+ et.abs_value_us = rd[i].expiration_time;
+ if (0 == (GNUNET_TIME_absolute_get_remaining (et)).rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"GNS_PHASE_DELEGATE_NS-%llu: This pkey is expired.\n",
rh->id);
- if (remaining_time.rel_value == 0)
+ if (remaining_time.rel_value_us == 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"GNS_PHASE_DELEGATE_NS-%llu: This dht entry is expired.\n",
@@ -3364,7 +3367,7 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"No shorten key for resolution\n");
- if (timeout.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
+ if (timeout.rel_value_us != GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
{
/*
* Set timeout for authority lookup phase to 1/2
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c
index ffc38c99b..4d12f02df 100644
--- a/src/gns/plugin_block_gns.c
+++ b/src/gns/plugin_block_gns.c
@@ -166,11 +166,12 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
record_match++;
}
}
- et.abs_value = exp;
+ et.abs_value_us = exp;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Verifying signature of %d records for name %s with expiration of %u\n",
- rd_count, name, et.abs_value);
+ "Verifying signature of %d records for name %s with expiration of %s\n",
+ rd_count, name,
+ GNUNET_STRINGS_absolute_time_to_string (et));
if (GNUNET_OK !=
GNUNET_NAMESTORE_verify_signature (&nrb->public_key,
diff --git a/src/gns/test_gns_dht_three_peers.c b/src/gns/test_gns_dht_three_peers.c
index 35a738aef..11f78db4b 100644
--- a/src/gns/test_gns_dht_three_peers.c
+++ b/src/gns/test_gns_dht_three_peers.c
@@ -250,12 +250,14 @@ on_lookup_result(void *cls, uint32_t rd_count,
end_now ();
}
+
static void
commence_testing(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
static int wait = 0;
+
wait++;
- if ((ZONE_PUT_WAIT_TIME.rel_value / 1000) == wait)
+ if ((ZONE_PUT_WAIT_TIME.rel_value_us / 1000LL / 1000LL) == wait)
{
fprintf (stderr, "\n");
wait_task = GNUNET_SCHEDULER_NO_TASK;
@@ -274,6 +276,7 @@ commence_testing(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
}
}
+
void
all_connected ()
{
diff --git a/src/gns/test_gns_proxy.c b/src/gns/test_gns_proxy.c
index cfbcb1d9e..050e2d258 100644
--- a/src/gns/test_gns_proxy.c
+++ b/src/gns/test_gns_proxy.c
@@ -422,7 +422,7 @@ run (void *cls,
}
host_key = GNUNET_CRYPTO_ecc_key_create_from_file (zone_keyfile);
- rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value;
+ rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
GNUNET_assert (GNUNET_OK == GNUNET_NAMESTORE_string_to_value (GNUNET_GNS_RECORD_A,
"127.0.0.1",
(void**)&rd.data,
diff --git a/src/gns/test_gns_pseu_shorten.c b/src/gns/test_gns_pseu_shorten.c
index 7413c7074..ba7cd2492 100644
--- a/src/gns/test_gns_pseu_shorten.c
+++ b/src/gns/test_gns_pseu_shorten.c
@@ -269,7 +269,7 @@ put_pseu_dht (void *cls, int success)
struct GNUNET_NAMESTORE_RecordData rd;
memset (&rd, 0, sizeof (struct GNUNET_NAMESTORE_RecordData));
- rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value;
+ rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
rd.data_size = strlen(TEST_PSEU_ALICE)+1;
rd.data = TEST_PSEU_ALICE;
rd.record_type = GNUNET_GNS_RECORD_PSEU;
diff --git a/src/gns/test_gns_simple_delegated_lookup.c b/src/gns/test_gns_simple_delegated_lookup.c
index ff19569d6..8b5f8bc38 100644
--- a/src/gns/test_gns_simple_delegated_lookup.c
+++ b/src/gns/test_gns_simple_delegated_lookup.c
@@ -247,7 +247,7 @@ do_check (void *cls,
GNUNET_TIME_UNIT_FOREVER_ABS,
TEST_RECORD_NAME,
&rd, 1);
- et.abs_value = rd.expiration_time;
+ et.abs_value_us = rd.expiration_time;
GNUNET_NAMESTORE_record_put (namestore_handle,
&bob_pkey,
TEST_RECORD_NAME,
diff --git a/src/gns/test_gns_simple_mx_lookup.c b/src/gns/test_gns_simple_mx_lookup.c
index 904758bde..b078edc4f 100644
--- a/src/gns/test_gns_simple_mx_lookup.c
+++ b/src/gns/test_gns_simple_mx_lookup.c
@@ -245,7 +245,7 @@ do_check (void *cls,
GNUNET_TIME_UNIT_FOREVER_ABS,
TEST_RECORD_NAME,
&rd, 1);
- et.abs_value = rd.expiration_time;
+ et.abs_value_us = rd.expiration_time;
GNUNET_NAMESTORE_record_put (namestore_handle,
&bob_pkey,
TEST_RECORD_NAME,
@@ -267,7 +267,7 @@ do_check (void *cls,
GNUNET_TIME_UNIT_FOREVER_ABS,
GNUNET_GNS_MASTERZONE_STR,
&rd, 1);
- et.abs_value = rd.expiration_time;
+ et.abs_value_us = rd.expiration_time;
GNUNET_NAMESTORE_record_put (namestore_handle,
&bob_pkey,
GNUNET_GNS_MASTERZONE_STR,
diff --git a/src/gns/test_gns_simple_srv_lookup.c b/src/gns/test_gns_simple_srv_lookup.c
index a403bf554..601d01af9 100644
--- a/src/gns/test_gns_simple_srv_lookup.c
+++ b/src/gns/test_gns_simple_srv_lookup.c
@@ -251,7 +251,7 @@ do_check (void *cls,
GNUNET_TIME_UNIT_FOREVER_ABS,
TEST_RECORD_NAME,
&rd, 1);
- et.abs_value = rd.expiration_time;
+ et.abs_value_us = rd.expiration_time;
GNUNET_NAMESTORE_record_put (namestore_handle,
&bob_pkey,
TEST_RECORD_NAME,
@@ -274,7 +274,7 @@ do_check (void *cls,
GNUNET_TIME_UNIT_FOREVER_ABS,
TEST_RECORD_NAME_SRV,
&rd, 1);
- et.abs_value = rd.expiration_time;
+ et.abs_value_us = rd.expiration_time;
GNUNET_NAMESTORE_record_put (namestore_handle,
&bob_pkey,
TEST_RECORD_NAME_SRV,
diff --git a/src/hello/hello.c b/src/hello/hello.c
index d2e143579..a6fe6102f 100644
--- a/src/hello/hello.c
+++ b/src/hello/hello.c
@@ -382,8 +382,8 @@ copy_latest (void *cls, const struct GNUNET_HELLO_Address *address,
ec.found = GNUNET_NO;
GNUNET_HELLO_iterate_addresses (mc->other, GNUNET_NO, &get_match_exp, &ec);
if ((ec.found == GNUNET_NO) ||
- (ec.expiration.abs_value < expiration.abs_value) ||
- ((ec.expiration.abs_value == expiration.abs_value) &&
+ (ec.expiration.abs_value_us < expiration.abs_value_us) ||
+ ((ec.expiration.abs_value_us == expiration.abs_value_us) &&
(mc->take_equal == GNUNET_YES)))
{
mc->ret +=
@@ -465,8 +465,8 @@ delta_match (void *cls, const struct GNUNET_HELLO_Address *address,
GNUNET_HELLO_iterate_addresses (dc->old_hello, GNUNET_NO, &get_match_exp,
&ec);
if ((ec.found == GNUNET_YES) &&
- ((ec.expiration.abs_value > expiration.abs_value) ||
- (ec.expiration.abs_value >= dc->expiration_limit.abs_value)))
+ ((ec.expiration.abs_value_us > expiration.abs_value_us) ||
+ (ec.expiration.abs_value_us >= dc->expiration_limit.abs_value_us)))
return GNUNET_YES; /* skip */
ret = dc->it (dc->it_cls, address, expiration);
return ret;
@@ -609,12 +609,12 @@ find_other_matching (void *cls, const struct GNUNET_HELLO_Address *address,
{
struct EqualsContext *ec = cls;
- if (expiration.abs_value < ec->expiration_limit.abs_value)
+ if (expiration.abs_value_us < ec->expiration_limit.abs_value_us)
return GNUNET_YES;
if (0 == GNUNET_HELLO_address_cmp (address, ec->address))
{
ec->found = GNUNET_YES;
- if (expiration.abs_value < ec->expiration.abs_value)
+ if (expiration.abs_value_us < ec->expiration.abs_value_us)
ec->result = GNUNET_TIME_absolute_min (expiration, ec->result);
return GNUNET_SYSERR;
}
@@ -628,7 +628,7 @@ find_matching (void *cls, const struct GNUNET_HELLO_Address *address,
{
struct EqualsContext *ec = cls;
- if (expiration.abs_value < ec->expiration_limit.abs_value)
+ if (expiration.abs_value_us < ec->expiration_limit.abs_value_us)
return GNUNET_YES;
ec->address = address;
ec->expiration = expiration;
@@ -677,7 +677,7 @@ GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1,
ec.result = GNUNET_TIME_UNIT_FOREVER_ABS;
ec.h2 = h2;
GNUNET_HELLO_iterate_addresses (h1, GNUNET_NO, &find_matching, &ec);
- if (ec.result.abs_value == GNUNET_TIME_UNIT_ZERO.rel_value)
+ if (ec.result.abs_value_us == GNUNET_TIME_UNIT_ZERO.rel_value_us)
return ec.result;
ec.h2 = h1;
GNUNET_HELLO_iterate_addresses (h2, GNUNET_NO, &find_matching, &ec);
@@ -707,7 +707,7 @@ GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg)
{
struct GNUNET_TIME_Absolute ret;
- ret.abs_value = 0;
+ ret.abs_value_us = 0;
GNUNET_HELLO_iterate_addresses (msg, GNUNET_NO, &find_min_expire, &ret);
return ret;
}
@@ -843,7 +843,7 @@ add_address_to_uri (void *cls, const struct GNUNET_HELLO_Address *address,
characters in URIs */
uri_addr = map_characters (addr_dup, "[]", "()");
GNUNET_free (addr_dup);
- seconds = expiration.abs_value / 1000;
+ seconds = expiration.abs_value_us / 1000LL / 1000LL;
t = gmtime (&seconds);
GNUNET_asprintf (&ret,
@@ -956,7 +956,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer)
GNUNET_break (0);
return 0;
}
- expire.abs_value = expiration_seconds * 1000;
+ expire.abs_value_us = expiration_seconds * 1000LL * 1000LL;
}
if ('!' != tname[0])
{
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c
index ad9b2b0b5..713d3cb04 100644
--- a/src/hostlist/hostlist-client.c
+++ b/src/hostlist/hostlist-client.c
@@ -793,7 +793,7 @@ task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
clean_up ();
return;
}
- if (GNUNET_TIME_absolute_get_remaining (end_time).rel_value == 0)
+ if (0 == GNUNET_TIME_absolute_get_remaining (end_time).rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Timeout trying to download hostlist from `%s'\n"),
@@ -1023,19 +1023,20 @@ task_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_SCHEDULER_add_now (&task_download_dispatcher, NULL);
delay = hostlist_delay;
- if (hostlist_delay.rel_value == 0)
+ if (0 == hostlist_delay.rel_value_us)
hostlist_delay = GNUNET_TIME_UNIT_SECONDS;
else
hostlist_delay = GNUNET_TIME_relative_multiply (hostlist_delay, 2);
- if (hostlist_delay.rel_value >
- GNUNET_TIME_UNIT_HOURS.rel_value * (1 + stat_connection_count))
+ if (hostlist_delay.rel_value_us >
+ GNUNET_TIME_UNIT_HOURS.rel_value_us * (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.rel_value, GNUNET_YES);
+ hostlist_delay.rel_value_us / 1000LL,
+ GNUNET_YES);
if (0 == once)
{
delay = GNUNET_TIME_UNIT_ZERO;
@@ -1194,8 +1195,9 @@ handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer,
&task_testing_intervall_reset, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Testing new hostlist advertisements is locked for the next %u ms\n",
- TESTING_INTERVAL.rel_value);
+ "Testing new hostlist advertisements is locked for the next %s\n",
+ GNUNET_STRINGS_relative_time_to_string (TESTING_INTERVAL,
+ GNUNET_YES));
ti_download_dispatcher_task =
GNUNET_SCHEDULER_add_now (&task_download_dispatcher, NULL);
@@ -1223,11 +1225,14 @@ primary_task (void *cls, int success)
}
+/**
+ * @param value previous delay value, in milliseconds (!)
+ */
static int
process_stat (void *cls, const char *subsystem, const char *name,
uint64_t value, int is_persistent)
{
- hostlist_delay.rel_value = value;
+ hostlist_delay.rel_value_us = value * 1000LL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Initial time between hostlist downloads is %s\n",
GNUNET_STRINGS_relative_time_to_string (hostlist_delay, GNUNET_YES));
@@ -1298,8 +1303,8 @@ load_hostlist_file ()
hostlist->hostlist_uri = (const char *) &hostlist[1];
memcpy (&hostlist[1], uri, strlen (uri) + 1);
hostlist->quality = quality;
- hostlist->time_creation.abs_value = created;
- hostlist->time_last_usage.abs_value = last_used;
+ hostlist->time_creation.abs_value_us = created;
+ hostlist->time_last_usage.abs_value_us = last_used;
GNUNET_CONTAINER_DLL_insert (linked_list_head, linked_list_tail, hostlist);
linked_list_size++;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1382,9 +1387,9 @@ save_hostlist_file (int shutdown)
(GNUNET_OK != GNUNET_BIO_write_int32 (wh, pos->times_used)) ||
(GNUNET_OK != GNUNET_BIO_write_int64 (wh, pos->quality)) ||
(GNUNET_OK !=
- GNUNET_BIO_write_int64 (wh, pos->time_last_usage.abs_value)) ||
+ GNUNET_BIO_write_int64 (wh, pos->time_last_usage.abs_value_us)) ||
(GNUNET_OK !=
- GNUNET_BIO_write_int64 (wh, pos->time_creation.abs_value)) ||
+ GNUNET_BIO_write_int64 (wh, pos->time_creation.abs_value_us)) ||
(GNUNET_OK != GNUNET_BIO_write_int32 (wh, pos->hello_count)))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c
index b9e1e6cf1..031c7a13e 100644
--- a/src/hostlist/hostlist-server.c
+++ b/src/hostlist/hostlist-server.c
@@ -155,7 +155,7 @@ check_has_addr (void *cls, const struct GNUNET_HELLO_Address *address,
{
int *arg = cls;
- if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0)
+ if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us)
{
GNUNET_STATISTICS_update (stats,
gettext_noop ("expired addresses encountered"), 1,
@@ -504,7 +504,7 @@ prepare_daemon (struct MHD_Daemon *daemon_handle)
GNUNET_assert (MHD_YES == MHD_get_fdset (daemon_handle, &rs, &ws, &es, &max));
haveto = MHD_get_timeout (daemon_handle, &timeout);
if (haveto == MHD_YES)
- tv.rel_value = (uint64_t) timeout;
+ tv.rel_value_us = (uint64_t) timeout;
else
tv = GNUNET_TIME_UNIT_FOREVER_REL;
GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1);
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c
index 84ecb8765..f4ef81f68 100644
--- a/src/identity/identity_api.c
+++ b/src/identity/identity_api.c
@@ -186,7 +186,7 @@ GNUNET_IDENTITY_ego_get_anonymous ()
if (NULL != anon.pk)
return &anon;
- anon.pk = GNUNET_CRYPTO_ecc_key_get_anonymous ();
+ anon.pk = (struct GNUNET_CRYPTO_EccPrivateKey *) GNUNET_CRYPTO_ecc_key_get_anonymous ();
GNUNET_CRYPTO_ecc_key_get_public (anon.pk,
&pub);
GNUNET_CRYPTO_hash (&pub, sizeof (pub), &anon.id);
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h
index bc5148de9..9a4bb6d6b 100644
--- a/src/include/gnunet_ats_service.h
+++ b/src/include/gnunet_ats_service.h
@@ -133,7 +133,7 @@ enum GNUNET_ATS_Property
* Delay
* Time between when the time packet is sent and the packet arrives
*
- * Unit: [ms]
+ * Unit: [microseconds]
*
* Examples:
*
@@ -905,8 +905,8 @@ enum GNUNET_ATS_PreferenceKind
* Change the peer's latency value to the given amount. The
* argument is followed by a double value giving the desired value
* (can be negative). The absolute score in the goal function is
- * the inverse of the latency in ms (minimum: 1 ms) multiplied by
- * the latency preferences.
+ * the inverse of the latency in microseconds (minimum: 1
+ * microsecond) multiplied by the latency preferences.
*/
GNUNET_ATS_PREFERENCE_LATENCY
};
diff --git a/src/include/gnunet_client_lib.h b/src/include/gnunet_client_lib.h
index e402b4295..5bfc4991f 100644
--- a/src/include/gnunet_client_lib.h
+++ b/src/include/gnunet_client_lib.h
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2013 Christian Grothoff (and other contributing authors)
+ (C) 2001-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
diff --git a/src/include/gnunet_resolver_service.h b/src/include/gnunet_resolver_service.h
index 498400dc3..f7e5c3b72 100644
--- a/src/include/gnunet_resolver_service.h
+++ b/src/include/gnunet_resolver_service.h
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
+ (C) 2001-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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h
index 1e2a4000a..c482a000c 100644
--- a/src/include/gnunet_scheduler_lib.h
+++ b/src/include/gnunet_scheduler_lib.h
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet
- (C) 2009, 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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
diff --git a/src/include/gnunet_server_lib.h b/src/include/gnunet_server_lib.h
index 2c64b4698..6ed862fc7 100644
--- a/src/include/gnunet_server_lib.h
+++ b/src/include/gnunet_server_lib.h
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2009, 2010 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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h
index 450417730..298f3284a 100644
--- a/src/include/gnunet_time_lib.h
+++ b/src/include/gnunet_time_lib.h
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
+ (C) 2001-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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -39,18 +39,18 @@ extern "C"
#include "gnunet_common.h"
/**
- * Time for absolute times used by GNUnet, in milliseconds.
+ * Time for absolute times used by GNUnet, in microseconds.
*/
struct GNUNET_TIME_Absolute
{
/**
* The actual value.
*/
- uint64_t abs_value;
+ uint64_t abs_value_us;
};
/**
- * Time for relative time used by GNUnet, in milliseconds.
+ * Time for relative time used by GNUnet, in microseconds.
* Always positive, so we can only refer to future time.
*/
struct GNUNET_TIME_Relative
@@ -58,32 +58,32 @@ struct GNUNET_TIME_Relative
/**
* The actual value.
*/
- uint64_t rel_value;
+ uint64_t rel_value_us;
};
GNUNET_NETWORK_STRUCT_BEGIN
/**
- * Time for relative time used by GNUnet, in milliseconds and in network byte order.
+ * Time for relative time used by GNUnet, in microseconds and in network byte order.
*/
struct GNUNET_TIME_RelativeNBO
{
/**
* The actual value (in network byte order).
*/
- uint64_t rel_value__ GNUNET_PACKED;
+ uint64_t rel_value_us__ GNUNET_PACKED;
};
/**
- * Time for absolute time used by GNUnet, in milliseconds and in network byte order.
+ * Time for absolute time used by GNUnet, in microseconds and in network byte order.
*/
struct GNUNET_TIME_AbsoluteNBO
{
/**
* The actual value (in network byte order).
*/
- uint64_t abs_value__ GNUNET_PACKED;
+ uint64_t abs_value_us__ GNUNET_PACKED;
};
GNUNET_NETWORK_STRUCT_END
@@ -98,9 +98,14 @@ GNUNET_NETWORK_STRUCT_END
#define GNUNET_TIME_UNIT_ZERO_ABS GNUNET_TIME_absolute_get_zero_()
/**
- * One millisecond, our basic time unit.
+ * One microsecond, our basic time unit.
*/
-#define GNUNET_TIME_UNIT_MILLISECONDS GNUNET_TIME_relative_get_unit_()
+#define GNUNET_TIME_UNIT_MICROSECONDS GNUNET_TIME_relative_get_unit_()
+
+/**
+ * One millisecond.
+ */
+#define GNUNET_TIME_UNIT_MILLISECONDS GNUNET_TIME_relative_get_millisecond_()
/**
* One second.
@@ -181,13 +186,20 @@ GNUNET_TIME_absolute_get_zero_ (void);
/**
- * Return relative time of 1ms.
+ * Return relative time of 1 microsecond.
*/
struct GNUNET_TIME_Relative
GNUNET_TIME_relative_get_unit_ (void);
/**
+ * Return relative time of 1ms.
+ */
+struct GNUNET_TIME_Relative
+GNUNET_TIME_relative_get_millisecond_ (void);
+
+
+/**
* Return relative time of 1s.
*/
struct GNUNET_TIME_Relative
diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c
index 6005e22db..23d851287 100644
--- a/src/mesh/gnunet-service-mesh-enc.c
+++ b/src/mesh/gnunet-service-mesh-enc.c
@@ -1926,8 +1926,8 @@ peer_get_oldest (void *cls,
if (GNUNET_YES == peer_is_used (p))
return GNUNET_YES;
- if (abs->abs_value < p->last_contact.abs_value)
- abs->abs_value = p->last_contact.abs_value;
+ if (abs->abs_value_us < p->last_contact.abs_value_us)
+ abs->abs_value_us = p->last_contact.abs_value_us;
return GNUNET_YES;
}
@@ -1948,7 +1948,7 @@ peer_timeout (void *cls,
struct MeshPeer *p = value;
struct GNUNET_TIME_Absolute *abs = cls;
- if (p->last_contact.abs_value == abs->abs_value &&
+ if (p->last_contact.abs_value_us == abs->abs_value_us &&
GNUNET_NO == peer_is_used (p))
{
peer_destroy (p);
@@ -3199,9 +3199,9 @@ rel_message_free (struct MeshReliableMessage *copy)
rel = copy->rel;
time = GNUNET_TIME_absolute_get_duration (copy->timestamp);
- rel->expected_delay.rel_value *= 7;
- rel->expected_delay.rel_value += time.rel_value;
- rel->expected_delay.rel_value /= 8;
+ rel->expected_delay.rel_value_us *= 7;
+ rel->expected_delay.rel_value_us += time.rel_value_us;
+ rel->expected_delay.rel_value_us /= 8;
rel->n_sent--;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! Freeing %u\n", copy->mid);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " n_sent %u\n", rel->n_sent);
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 0dfac410d..9b4e4ad72 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -2709,9 +2709,9 @@ tunnel_free_reliable_message (struct MeshReliableMessage *copy)
rel = copy->rel;
time = GNUNET_TIME_absolute_get_duration (copy->timestamp);
- rel->expected_delay.rel_value *= 7;
- rel->expected_delay.rel_value += time.rel_value;
- rel->expected_delay.rel_value /= 8;
+ rel->expected_delay.rel_value_us *= 7;
+ rel->expected_delay.rel_value_us += time.rel_value_us;
+ rel->expected_delay.rel_value_us /= 8;
rel->n_sent--;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! Freeing %u\n", copy->mid);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " n_sent %u\n", rel->n_sent);
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c
index 5daad36e2..1beebf9c1 100644
--- a/src/mesh/mesh_api.c
+++ b/src/mesh/mesh_api.c
@@ -564,7 +564,7 @@ add_to_queue (struct GNUNET_MESH_Handle *h,
struct GNUNET_MESH_TransmitHandle *th)
{
GNUNET_CONTAINER_DLL_insert_tail (h->th_head, h->th_tail, th);
- if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value == th->timeout.abs_value)
+ if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == th->timeout.abs_value_us)
return;
th->timeout_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
diff --git a/src/mesh/mesh_api_enc.c b/src/mesh/mesh_api_enc.c
index 3401f5d33..113ff46d0 100644
--- a/src/mesh/mesh_api_enc.c
+++ b/src/mesh/mesh_api_enc.c
@@ -551,7 +551,7 @@ add_to_queue (struct GNUNET_MESH_Handle *h,
struct GNUNET_MESH_TransmitHandle *th)
{
GNUNET_CONTAINER_DLL_insert_tail (h->th_head, h->th_tail, th);
- if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value == th->timeout.abs_value)
+ if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == th->timeout.abs_value_us)
return;
th->timeout_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
diff --git a/src/mesh/test_mesh_small.c b/src/mesh/test_mesh_small.c
index 30ea49223..dc9f9461c 100644
--- a/src/mesh/test_mesh_small.c
+++ b/src/mesh/test_mesh_small.c
@@ -192,14 +192,15 @@ show_end_data (void)
end_time = GNUNET_TIME_absolute_get();
total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
- FPRINTF (stderr, "Test time %llu ms\n",
- (unsigned long long) total_time.rel_value);
+ FPRINTF (stderr, "Test time %s\n",
+ GNUNET_STRINGS_relative_time_to_string (total_time,
+ GNUNET_YES));
FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
- 4 * TOTAL_PACKETS * 1.0 / total_time.rel_value); // 4bytes * ms
+ 4 * TOTAL_PACKETS * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
- TOTAL_PACKETS * 1000.0 / total_time.rel_value); // packets * ms
+ TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
GAUGER ("MESH", test_name,
- TOTAL_PACKETS * 1000.0 / total_time.rel_value,
+ TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000),
"packets/s");
}
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 50a8601f8..d0f68b78e 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -345,12 +345,12 @@ display_record (void *cls,
}
if (0 != (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION))
{
- rex.rel_value = rd[i].expiration_time;
+ rex.rel_value_us = rd[i].expiration_time;
etime = GNUNET_STRINGS_relative_time_to_string (rex, GNUNET_YES);
}
else
{
- aex.abs_value = rd[i].expiration_time;
+ aex.abs_value_us = rd[i].expiration_time;
etime = GNUNET_STRINGS_absolute_time_to_string (aex);
}
FPRINTF (stdout, "\t%s: %s (%s %s)\n", typestring, s,
@@ -418,12 +418,12 @@ get_existing_record (void *cls,
rde->record_type = type;
if (GNUNET_YES == etime_is_rel)
{
- rde->expiration_time = etime_rel.rel_value;
+ rde->expiration_time = etime_rel.rel_value_us;
rde->flags |= GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
}
else if (GNUNET_NO == etime_is_rel)
{
- rde->expiration_time = etime_abs.abs_value;
+ rde->expiration_time = etime_abs.abs_value_us;
}
if (1 != nonauthority)
rde->flags |= GNUNET_NAMESTORE_RF_AUTHORITY;
@@ -658,13 +658,13 @@ testservice_task (void *cls,
rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY;
if (GNUNET_YES == etime_is_rel)
{
- rd.expiration_time = etime_rel.rel_value;
+ rd.expiration_time = etime_rel.rel_value_us;
rd.flags |= GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
}
else if (GNUNET_NO == etime_is_rel)
- rd.expiration_time = etime_abs.abs_value;
+ rd.expiration_time = etime_abs.abs_value_us;
else
- rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value;
+ rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
if (1 != nonauthority)
rd.flags |= GNUNET_NAMESTORE_RF_AUTHORITY;
add_qe_uri = GNUNET_NAMESTORE_record_put_by_authority (ns,
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index a4e463642..749552dca 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -442,12 +442,12 @@ get_block_expiration_time (unsigned int rd_count, const struct GNUNET_NAMESTORE_
{
if (0 != (rd[c].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION))
{
- rt.rel_value = rd[c].expiration_time;
+ rt.rel_value_us = rd[c].expiration_time;
at = GNUNET_TIME_relative_to_absolute (rt);
}
else
{
- at.abs_value = rd[c].expiration_time;
+ at.abs_value_us = rd[c].expiration_time;
}
expire = GNUNET_TIME_absolute_min (at, expire);
}
@@ -742,16 +742,16 @@ handle_lookup_name_it (void *cls,
{
GNUNET_break (GNUNET_YES == authoritative);
rd_modified = GNUNET_YES;
- re.rel_value = rd[c].expiration_time;
+ re.rel_value_us = rd[c].expiration_time;
e = GNUNET_TIME_relative_to_absolute (re);
}
else
{
- e.abs_value = rd[c].expiration_time;
+ e.abs_value_us = rd[c].expiration_time;
}
/* found matching record, copy and convert flags to public format */
rd_selected[copied_elements] = rd[c]; /* shallow copy! */
- rd_selected[copied_elements].expiration_time = e.abs_value;
+ rd_selected[copied_elements].expiration_time = e.abs_value_us;
if (0 != (rd_selected[copied_elements].flags &
(GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION | GNUNET_NAMESTORE_RF_AUTHORITY)))
{
@@ -1609,8 +1609,8 @@ zone_iteraterate_proc (void *cls,
(0 != (rd[c].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)) )
{
/* should convert relative-to-absolute expiration time */
- rt.rel_value = rd[c].expiration_time;
- rd_filtered[c].expiration_time = GNUNET_TIME_relative_to_absolute (rt).abs_value;
+ rt.rel_value_us = rd[c].expiration_time;
+ rd_filtered[c].expiration_time = GNUNET_TIME_relative_to_absolute (rt).abs_value_us;
rd_filtered[c].flags &= ~ GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
}
/* we NEVER keep the 'authority' flag */
@@ -1637,10 +1637,10 @@ zone_iteraterate_proc (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Creating signature for `%s' in zone `%s' with %u records and expiration %llu\n",
+ "Creating signature for `%s' in zone `%s' with %u records and expiration %s\n",
name, GNUNET_NAMESTORE_short_h2s(&zone_hash),
rd_count_filtered,
- (unsigned long long) expire.abs_value);
+ GNUNET_STRINGS_absolute_time_to_string (expire));
/* TODO 1) AB: New publishing
* - Create HDKF(Q,i)
* - Encrypt record block R with HKDF: HDKF(Q,i) == E(R)
@@ -1671,9 +1671,9 @@ zone_iteraterate_proc (void *cls,
if (NULL != signature)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Using provided signature for `%s' in zone `%s' with %u records and expiration %llu\n",
+ "Using provided signature for `%s' in zone `%s' with %u records and expiration %s\n",
name, GNUNET_NAMESTORE_short_h2s (&zone_hash), rd_count_filtered,
- (unsigned long long) expire.abs_value);
+ GNUNET_STRINGS_absolute_time_to_string (expire));
return;
}
}
diff --git a/src/namestore/namestore_api_common.c b/src/namestore/namestore_api_common.c
index d8fede7d2..7098e6131 100644
--- a/src/namestore/namestore_api_common.c
+++ b/src/namestore/namestore_api_common.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2009, 2010, 2012 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
@@ -747,8 +747,8 @@ GNUNET_NAMESTORE_is_expired (const struct GNUNET_NAMESTORE_RecordData *rd)
if (0 != (rd->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION))
return GNUNET_NO;
- at.abs_value = rd->expiration_time;
- return (0 == GNUNET_TIME_absolute_get_remaining (at).rel_value) ? GNUNET_YES : GNUNET_NO;
+ at.abs_value_us = rd->expiration_time;
+ return (0 == GNUNET_TIME_absolute_get_remaining (at).rel_value_us) ? GNUNET_YES : GNUNET_NO;
}
diff --git a/src/namestore/plugin_namestore_postgres.c b/src/namestore/plugin_namestore_postgres.c
index 64bfa631c..b62c306f3 100644
--- a/src/namestore/plugin_namestore_postgres.c
+++ b/src/namestore/plugin_namestore_postgres.c
@@ -311,7 +311,7 @@ namestore_postgres_put_records (void *cls,
}
{
char data[data_size];
- uint64_t expire_be = GNUNET_htonll (expire.abs_value);
+ uint64_t expire_be = GNUNET_htonll (expire.abs_value_us);
uint64_t rvalue_be = GNUNET_htonll (rvalue);
uint32_t rd_count_be = htonl ((uint32_t) rd_count);
const char *paramValues[] = {
@@ -421,7 +421,7 @@ get_record_and_call_iterator (struct Plugin *plugin,
record_count = ntohl (*(uint32_t *) PQgetvalue (res, 0, 2));
data_size = PQgetlength (res, 0, 3);
data = PQgetvalue (res, 0, 3);
- expiration.abs_value =
+ expiration.abs_value_us =
GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, 0, 4));
sig = (const struct GNUNET_CRYPTO_EccSignature*) PQgetvalue (res, 0, 5);
if (record_count > 64 * 1024)
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c
index 6ee3de495..a7cc03434 100644
--- a/src/namestore/plugin_namestore_sqlite.c
+++ b/src/namestore/plugin_namestore_sqlite.c
@@ -501,7 +501,7 @@ namestore_sqlite_put_records (void *cls,
(SQLITE_OK != sqlite3_bind_text (plugin->put_records, 2, name, -1, SQLITE_STATIC)) ||
(SQLITE_OK != sqlite3_bind_int (plugin->put_records, 3, rd_count)) ||
(SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 4, data, data_size, SQLITE_STATIC)) ||
- (SQLITE_OK != sqlite3_bind_int64 (plugin->put_records, 5, expire.abs_value)) ||
+ (SQLITE_OK != sqlite3_bind_int64 (plugin->put_records, 5, expire.abs_value_us)) ||
(SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 6, signature, sizeof (struct GNUNET_CRYPTO_EccSignature), SQLITE_STATIC)) ||
(SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 7, &zone_delegation, sizeof (struct GNUNET_CRYPTO_ShortHashCode), SQLITE_STATIC)) ||
(SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 8, &zone, sizeof (struct GNUNET_CRYPTO_ShortHashCode), SQLITE_STATIC)) ||
@@ -575,7 +575,7 @@ get_record_and_call_iterator (struct Plugin *plugin,
record_count = sqlite3_column_int (stmt, 2);
data_size = sqlite3_column_bytes (stmt, 3);
data = sqlite3_column_blob (stmt, 3);
- expiration.abs_value = (uint64_t) sqlite3_column_int64 (stmt, 4);
+ expiration.abs_value_us = (uint64_t) sqlite3_column_int64 (stmt, 4);
sig = sqlite3_column_blob (stmt, 5);
if ( (sizeof (struct GNUNET_CRYPTO_EccPublicKey) != sqlite3_column_bytes (stmt, 0)) ||
diff --git a/src/namestore/test_namestore_api.c b/src/namestore/test_namestore_api.c
index 3397b35f1..3d921f132 100644
--- a/src/namestore/test_namestore_api.c
+++ b/src/namestore/test_namestore_api.c
@@ -153,7 +153,7 @@ run (void *cls,
GNUNET_CRYPTO_ecc_key_get_public (privkey, &pubkey);
GNUNET_CRYPTO_short_hash (&pubkey, sizeof (pubkey), &zone);
memset (&signature, '\0', sizeof (signature));
- rd.expiration_time = GNUNET_TIME_absolute_get().abs_value;
+ rd.expiration_time = GNUNET_TIME_absolute_get().abs_value_us;
rd.record_type = TEST_RECORD_TYPE;
rd.data_size = TEST_RECORD_DATALEN;
rd.data = GNUNET_malloc (TEST_RECORD_DATALEN);
diff --git a/src/namestore/test_namestore_api_create.c b/src/namestore/test_namestore_api_create.c
index 4eac96df6..667bf0827 100644
--- a/src/namestore/test_namestore_api_create.c
+++ b/src/namestore/test_namestore_api_create.c
@@ -316,7 +316,7 @@ create_record (unsigned int count)
rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
for (c = 0; c < count; c++)
{
- rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value;
+ rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us;
rd[c].record_type = TEST_RECORD_TYPE;
rd[c].data_size = TEST_RECORD_DATALEN;
rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
diff --git a/src/namestore/test_namestore_api_create_update.c b/src/namestore/test_namestore_api_create_update.c
index f1e66963f..90d36ccb6 100644
--- a/src/namestore/test_namestore_api_create_update.c
+++ b/src/namestore/test_namestore_api_create_update.c
@@ -146,7 +146,7 @@ create_identical_cont (void *cls, int32_t success, const char *emsg)
if (success == GNUNET_OK)
{
res = 0;
- s_first_record->expiration_time = GNUNET_TIME_absolute_get ().abs_value;
+ s_first_record->expiration_time = GNUNET_TIME_absolute_get ().abs_value_us;
GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name,
1, s_first_record,
&create_updated_cont, s_name);
@@ -239,7 +239,7 @@ run (void *cls,
char rd_ser[rd_ser_len];
GNUNET_NAMESTORE_records_serialize(1, s_first_record, rd_ser_len, rd_ser);
- et.abs_value = s_first_record->expiration_time;
+ et.abs_value_us = s_first_record->expiration_time;
s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_first_record, 1);
/* create random zone hash */
diff --git a/src/namestore/test_namestore_api_lookup.c b/src/namestore/test_namestore_api_lookup.c
index d8f6fe056..24ef4c74e 100644
--- a/src/namestore/test_namestore_api_lookup.c
+++ b/src/namestore/test_namestore_api_lookup.c
@@ -200,7 +200,7 @@ create_record (unsigned int count)
rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
for (c = 0; c < count; c++)
{
- rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value;
+ rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us;
rd[c].record_type = TEST_RECORD_TYPE;
rd[c].data_size = TEST_RECORD_DATALEN;
rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
@@ -237,7 +237,7 @@ run (void *cls,
GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser);
/* sign */
- et.abs_value = s_rd[0].expiration_time;
+ et.abs_value_us = s_rd[0].expiration_time;
s_signature = GNUNET_NAMESTORE_create_signature (privkey, et, s_name,
s_rd, RECORDS);
diff --git a/src/namestore/test_namestore_api_lookup_specific_type.c b/src/namestore/test_namestore_api_lookup_specific_type.c
index 28632c83f..1d084dbc1 100644
--- a/src/namestore/test_namestore_api_lookup_specific_type.c
+++ b/src/namestore/test_namestore_api_lookup_specific_type.c
@@ -250,13 +250,13 @@ create_record (unsigned int count)
rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
for (c = 0; c < count-1; c++)
{
- rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value;
+ rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us;
rd[c].record_type = 1;
rd[c].data_size = TEST_RECORD_DATALEN;
rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
}
- rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value;
+ rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us;
rd[c].record_type = TEST_RECORD_LOOKUP_TYPE_EXISTING;
rd[c].data_size = TEST_RECORD_DATALEN;
rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
@@ -296,7 +296,7 @@ run (void *cls,
GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser);
/* sign */
- et.abs_value = s_rd[RECORDS - 1].expiration_time;
+ et.abs_value_us = s_rd[RECORDS - 1].expiration_time;
s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_rd, RECORDS);
/* create random zone hash */
diff --git a/src/namestore/test_namestore_api_monitoring.c b/src/namestore/test_namestore_api_monitoring.c
index c103952fa..f60116a79 100644
--- a/src/namestore/test_namestore_api_monitoring.c
+++ b/src/namestore/test_namestore_api_monitoring.c
@@ -219,7 +219,7 @@ create_record (unsigned int count)
rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
for (c = 0; c < count; c++)
{
- rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value;
+ rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us;
rd[c].record_type = 1111;
rd[c].data_size = 50;
rd[c].data = GNUNET_malloc(50);
@@ -282,7 +282,7 @@ run (void *cls,
GNUNET_asprintf(&s_name_1, "dummy1");
s_rd_1 = create_record(1);
- et.abs_value = s_rd_1->expiration_time;
+ et.abs_value_us = s_rd_1->expiration_time;
sig_1 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_1, s_rd_1, 1);
GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name_1,
1, s_rd_1,
@@ -293,7 +293,7 @@ run (void *cls,
GNUNET_asprintf(&s_name_2, "dummy2");
s_rd_2 = create_record(1);
- et.abs_value = s_rd_2->expiration_time;
+ et.abs_value_us = s_rd_2->expiration_time;
sig_2 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_2, s_rd_2, 1);
GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name_2,
1, s_rd_2,
@@ -303,7 +303,7 @@ run (void *cls,
/* name in different zone */
GNUNET_asprintf(&s_name_3, "dummy3");
s_rd_3 = create_record(1);
- et.abs_value = s_rd_3->expiration_time;
+ et.abs_value_us = s_rd_3->expiration_time;
sig_3 = GNUNET_NAMESTORE_create_signature(privkey2, et, s_name_3, s_rd_3, 1);
GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3,
GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3,
diff --git a/src/namestore/test_namestore_api_put.c b/src/namestore/test_namestore_api_put.c
index ff99b60f9..ccbe8eefe 100644
--- a/src/namestore/test_namestore_api_put.c
+++ b/src/namestore/test_namestore_api_put.c
@@ -121,7 +121,7 @@ create_record (unsigned int count)
rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
for (c = 0; c < count; c++)
{
- rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value;
+ rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value_us;
rd[c].record_type = TEST_RECORD_TYPE;
rd[c].data_size = TEST_RECORD_DATALEN;
rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
@@ -157,7 +157,7 @@ run (void *cls,
/* create record */
s_name = GNUNET_NAMESTORE_normalize_string ("DUMMY.dummy.gnunet");
s_rd = create_record (RECORDS);
- et.abs_value = s_rd[0].expiration_time;
+ et.abs_value_us = s_rd[0].expiration_time;
signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_rd, RECORDS);
GNUNET_break (s_rd != NULL);
GNUNET_break (s_name != NULL);
diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c
index f278b30db..19721f5a1 100644
--- a/src/namestore/test_namestore_api_remove.c
+++ b/src/namestore/test_namestore_api_remove.c
@@ -203,14 +203,14 @@ create_record (unsigned int count)
struct GNUNET_NAMESTORE_RecordData * rd;
rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
- rd[0].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value;
+ rd[0].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us;
rd[0].record_type = 0;
rd[0].data_size = TEST_REMOVE_RECORD_DATALEN;
rd[0].data = GNUNET_malloc(TEST_REMOVE_RECORD_DATALEN);
memset ((char *) rd[0].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
for (c = 1; c < count; c++)
{
- rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value;
+ rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us;
rd[c].record_type = TEST_RECORD_TYPE;
rd[c].data_size = TEST_RECORD_DATALEN;
rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
@@ -250,7 +250,7 @@ run (void *cls,
GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser);
/* sign */
- et.abs_value = s_rd[0].expiration_time;
+ et.abs_value_us = s_rd[0].expiration_time;
s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_rd, RECORDS);
/* create random zone hash */
diff --git a/src/namestore/test_namestore_api_remove_not_existing_record.c b/src/namestore/test_namestore_api_remove_not_existing_record.c
index a85bc8c05..6247ff346 100644
--- a/src/namestore/test_namestore_api_remove_not_existing_record.c
+++ b/src/namestore/test_namestore_api_remove_not_existing_record.c
@@ -158,7 +158,7 @@ create_record (unsigned int count)
rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
for (c = 0; c < count; c++)
{
- rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value;
+ rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value_us;
rd[c].record_type = TEST_RECORD_TYPE;
rd[c].data_size = TEST_RECORD_DATALEN;
rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
@@ -198,7 +198,7 @@ run (void *cls,
GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser);
/* sign */
- et.abs_value = s_rd[0].expiration_time;
+ et.abs_value_us = s_rd[0].expiration_time;
s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_rd, RECORDS);
/* create random zone hash */
diff --git a/src/namestore/test_namestore_api_sign_verify.c b/src/namestore/test_namestore_api_sign_verify.c
index e2913991c..41b9407e4 100644
--- a/src/namestore/test_namestore_api_sign_verify.c
+++ b/src/namestore/test_namestore_api_sign_verify.c
@@ -62,7 +62,7 @@ create_record (int count)
rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
for (c = 0; c < count; c++)
{
- rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value;
+ rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value_us;
rd[c].record_type = TEST_RECORD_TYPE;
rd[c].data_size = TEST_RECORD_DATALEN;
rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
diff --git a/src/namestore/test_namestore_api_zone_iteration.c b/src/namestore/test_namestore_api_zone_iteration.c
index 63e4adf40..036944e9a 100644
--- a/src/namestore/test_namestore_api_zone_iteration.c
+++ b/src/namestore/test_namestore_api_zone_iteration.c
@@ -195,7 +195,9 @@ zone_proc (void *cls,
else
res = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received last result, iteration done after receing %u results\n",returned_records );
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received last result, iteration done after receing %u results\n",
+ returned_records );
GNUNET_SCHEDULER_add_now (&end, NULL);
}
else
@@ -205,7 +207,10 @@ zone_proc (void *cls,
{
struct GNUNET_HashCode zone_key_hash;
GNUNET_CRYPTO_hash (zone_key, sizeof (struct GNUNET_CRYPTO_EccPublicKey), &zone_key_hash);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Verifying signature for `%s' in zone `%s' with %u records and expiration %llu failed\n", name, GNUNET_h2s(&zone_key_hash), rd_count, expire.abs_value);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Verifying signature for `%s' in zone `%s' with %u records and expiration %s failed\n",
+ name, GNUNET_h2s(&zone_key_hash), rd_count,
+ GNUNET_STRINGS_absolute_time_to_string (expire));
failed = GNUNET_YES;
GNUNET_break (0);
@@ -337,7 +342,7 @@ create_record (unsigned int count)
rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
for (c = 0; c < count; c++)
{
- rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value;
+ rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us;
rd[c].record_type = 1111;
rd[c].data_size = 50;
rd[c].data = GNUNET_malloc(50);
@@ -392,7 +397,7 @@ empty_zone_proc (void *cls,
GNUNET_asprintf(&s_name_1, "dummy1");
s_rd_1 = create_record(1);
- et.abs_value = s_rd_1->expiration_time;
+ et.abs_value_us = s_rd_1->expiration_time;
sig_1 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_1, s_rd_1, 1);
GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name_1,
1, s_rd_1,
@@ -403,7 +408,7 @@ empty_zone_proc (void *cls,
GNUNET_asprintf(&s_name_2, "dummy2");
s_rd_2 = create_record(1);
- et.abs_value = s_rd_2->expiration_time;
+ et.abs_value_us = s_rd_2->expiration_time;
sig_2 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_2, s_rd_2, 1);
GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name_2,
1, s_rd_2,
@@ -413,7 +418,7 @@ empty_zone_proc (void *cls,
/* name in different zone */
GNUNET_asprintf(&s_name_3, "dummy3");
s_rd_3 = create_record(1);
- et.abs_value = s_rd_3->expiration_time;
+ et.abs_value_us = s_rd_3->expiration_time;
sig_3 = GNUNET_NAMESTORE_create_signature(privkey2, et, s_name_3, s_rd_3, 1);
GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL);
}
diff --git a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
index 020c8358f..d0db013b7 100644
--- a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
+++ b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
@@ -302,7 +302,7 @@ create_record (unsigned int count)
rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
for (c = 0; c < count; c++)
{
- rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value;
+ rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us;
rd[c].record_type = 1111;
rd[c].data_size = 50;
rd[c].data = GNUNET_malloc(50);
@@ -344,7 +344,7 @@ run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n");
GNUNET_asprintf(&s_name_1, "dummy1");
s_rd_1 = create_record(1);
- et.abs_value = s_rd_1[0].expiration_time;
+ et.abs_value_us = s_rd_1[0].expiration_time;
sig_1 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_1, s_rd_1, 1);
GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name_1,
1, s_rd_1,
@@ -353,7 +353,7 @@ run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n");
GNUNET_asprintf(&s_name_2, "dummy2");
s_rd_2 = create_record(1);
- et.abs_value = s_rd_2[0].expiration_time;
+ et.abs_value_us = s_rd_2[0].expiration_time;
sig_2 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_2, s_rd_2, 1);
GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name_2,
1, s_rd_2,
@@ -363,7 +363,7 @@ run (void *cls,
/* name in different zone */
GNUNET_asprintf(&s_name_3, "dummy3");
s_rd_3 = create_record(1);
- et.abs_value = s_rd_3[0].expiration_time;
+ et.abs_value_us = s_rd_3[0].expiration_time;
sig_3 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_3, s_rd_3, 1);
GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3,
GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL);
diff --git a/src/namestore/test_namestore_api_zone_iteration_stop.c b/src/namestore/test_namestore_api_zone_iteration_stop.c
index 5d44555d1..abd7c2564 100644
--- a/src/namestore/test_namestore_api_zone_iteration_stop.c
+++ b/src/namestore/test_namestore_api_zone_iteration_stop.c
@@ -361,7 +361,7 @@ create_record (unsigned int count)
rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
for (c = 0; c < count; c++)
{
- rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value;
+ rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us;
rd[c].record_type = 1111;
rd[c].data_size = 50;
rd[c].data = GNUNET_malloc(50);
@@ -405,7 +405,7 @@ run (void *cls,
GNUNET_asprintf(&s_name_1, "dummy1");
s_rd_1 = create_record(1);
- et.abs_value = s_rd_1[0].expiration_time;
+ et.abs_value_us = s_rd_1[0].expiration_time;
sig_1 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_1, s_rd_1, 1);
GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name_1,
1, s_rd_1, &put_cont, NULL);
@@ -415,7 +415,7 @@ run (void *cls,
GNUNET_asprintf(&s_name_2, "dummy2");
s_rd_2 = create_record(1);
- et.abs_value = s_rd_2[0].expiration_time;
+ et.abs_value_us = s_rd_2[0].expiration_time;
sig_2 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_2, s_rd_2, 1);
GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name_2,
1, s_rd_2, &put_cont, NULL);
@@ -424,7 +424,7 @@ run (void *cls,
/* name in different zone */
GNUNET_asprintf(&s_name_3, "dummy3");
s_rd_3 = create_record(1);
- et.abs_value = s_rd_3[0].expiration_time;
+ et.abs_value_us = s_rd_3[0].expiration_time;
sig_3 = GNUNET_NAMESTORE_create_signature(privkey2, et, s_name_3, s_rd_3, 1);
GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL);
}
diff --git a/src/namestore/test_namestore_api_zone_to_name.c b/src/namestore/test_namestore_api_zone_to_name.c
index e1fefec09..ea242c49e 100644
--- a/src/namestore/test_namestore_api_zone_to_name.c
+++ b/src/namestore/test_namestore_api_zone_to_name.c
@@ -187,7 +187,7 @@ run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using PKEY `%s' \n", GNUNET_NAMESTORE_short_h2s (&s_zone_value));
struct GNUNET_NAMESTORE_RecordData rd;
- rd.expiration_time = GNUNET_TIME_absolute_get().abs_value;
+ rd.expiration_time = GNUNET_TIME_absolute_get().abs_value_us;
rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY;
rd.data_size = sizeof (struct GNUNET_CRYPTO_ShortHashCode);
rd.data = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_ShortHashCode));
@@ -196,7 +196,7 @@ run (void *cls,
GNUNET_break (NULL != nsh);
expire = GNUNET_TIME_absolute_get ();
- et.abs_value = rd.expiration_time;
+ et.abs_value_us = rd.expiration_time;
s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, &rd, 1);
GNUNET_NAMESTORE_record_put(nsh, &pubkey, s_name, expire, 1, &rd, s_signature, put_cont, NULL);
diff --git a/src/namestore/test_plugin_namestore.c b/src/namestore/test_plugin_namestore.c
index 35c9e920f..4b5a75b5e 100644
--- a/src/namestore/test_plugin_namestore.c
+++ b/src/namestore/test_plugin_namestore.c
@@ -154,7 +154,7 @@ put_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id)
{
rd[i].data = "Hello World";
rd[i].data_size = id % 10;
- rd[i].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES).abs_value;
+ rd[i].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES).abs_value_us;
rd[i].record_type = 1 + (id % 13);
rd[i].flags = (id % 7);
}
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c
index d55e61e60..b6f1c463a 100644
--- a/src/nse/gnunet-nse-profiler.c
+++ b/src/nse/gnunet-nse-profiler.c
@@ -366,7 +366,7 @@ handle_estimate (void *cls,
sizeof (output_buffer),
"%p %llu %llu %f %f %f\n",
peer, peers_running,
- timestamp.abs_value,
+ (unsigned long long) timestamp.abs_value_us,
GNUNET_NSE_log_estimate_to_n (estimate), estimate,
std_dev);
if (size != GNUNET_DISK_file_write (output_file, output_buffer, size))
@@ -435,7 +435,8 @@ stat_iterator (void *cls, const char *subsystem, const char *name,
if (0 != flag)
flag = 1;
size = GNUNET_asprintf (&output_buffer, "%llu %llu %u\n",
- now.abs_value/1000, value, flag);
+ now.abs_value_us / 1000LL / 1000LL,
+ value, flag);
if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c
index 832c43abc..978712d53 100644
--- a/src/nse/gnunet-service-nse.c
+++ b/src/nse/gnunet-service-nse.c
@@ -440,8 +440,8 @@ get_matching_bits_delay (uint32_t matching_bits)
// f is frequency (gnunet_nse_interval)
// x is matching_bits
// p' is current_size_estimate
- return ((double) gnunet_nse_interval.rel_value / (double) 2.0) -
- ((gnunet_nse_interval.rel_value / M_PI) *
+ return ((double) gnunet_nse_interval.rel_value_us / (double) 2.0) -
+ ((gnunet_nse_interval.rel_value_us / M_PI) *
atan (matching_bits - current_size_estimate));
}
@@ -462,10 +462,12 @@ get_delay_randomization (uint32_t matching_bits)
d = get_matching_bits_delay (matching_bits);
i = (uint32_t) (d / (double) (hop_count_max + 1));
+ ret.rel_value_us = i;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Randomizing flood using latencies up to %u ms\n",
- (unsigned int) i);
- ret.rel_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, i + 1);
+ "Randomizing flood using latencies up to %s\n",
+ GNUNET_STRINGS_relative_time_to_string (ret,
+ GNUNET_YES));
+ ret.rel_value_us = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, i + 1);
return ret;
#else
return GNUNET_TIME_UNIT_ZERO;
@@ -508,7 +510,7 @@ get_matching_bits (struct GNUNET_TIME_Absolute timestamp,
{
struct GNUNET_HashCode timestamp_hash;
- GNUNET_CRYPTO_hash (&timestamp.abs_value, sizeof (timestamp.abs_value),
+ GNUNET_CRYPTO_hash (&timestamp.abs_value_us, sizeof (timestamp.abs_value_us),
&timestamp_hash);
return GNUNET_CRYPTO_hash_matching_bits (&timestamp_hash, &id->hashPubKey);
}
@@ -535,26 +537,27 @@ get_transmit_delay (int round_offset)
case -1:
/* previous round is randomized between 0 and 50 ms */
#if USE_RANDOM_DELAYS
- ret.rel_value = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 50);
+ ret.rel_value_us = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 50);
#else
ret = GNUNET_TIME_UNIT_ZERO;
#endif
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Transmitting previous round behind schedule in %llu ms\n",
- (unsigned long long) ret.rel_value);
+ "Transmitting previous round behind schedule in %s\n",
+ GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES));
return ret;
case 0:
/* current round is based on best-known matching_bits */
matching_bits =
ntohl (size_estimate_messages[estimate_index].matching_bits);
dist_delay = get_matching_bits_delay (matching_bits);
- dist_delay += get_delay_randomization (matching_bits).rel_value;
- ret.rel_value = (uint64_t) dist_delay;
+ dist_delay += get_delay_randomization (matching_bits).rel_value_us;
+ ret.rel_value_us = (uint64_t) dist_delay;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "For round %llu, delay for %u matching bits is %llu ms\n",
- (unsigned long long) current_timestamp.abs_value,
+ "For round %s, delay for %u matching bits is %s\n",
+ GNUNET_STRINGS_absolute_time_to_string (current_timestamp),
(unsigned int) matching_bits,
- (unsigned long long) ret.rel_value);
+ GNUNET_STRINGS_relative_time_to_string (ret,
+ GNUNET_YES));
/* now consider round start time and add delay to it */
tgt = GNUNET_TIME_absolute_add (current_timestamp, ret);
return GNUNET_TIME_absolute_get_remaining (tgt);
@@ -621,10 +624,8 @@ transmit_ready (void *cls, size_t size, void *buf)
return 0;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "In round %llu, sending to `%s' estimate with %u bits\n",
- (unsigned long long)
- GNUNET_TIME_absolute_ntoh (size_estimate_messages[idx].
- timestamp).abs_value,
+ "In round s, sending to `%s' estimate with %u bits\n",
+ GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (size_estimate_messages[idx].timestamp)),
GNUNET_i2s (&peer_entry->id),
(unsigned int) ntohl (size_estimate_messages[idx].matching_bits));
if (ntohl (size_estimate_messages[idx].hop_count) == 0)
@@ -778,7 +779,7 @@ update_flood_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
offset = GNUNET_TIME_absolute_get_remaining (next_timestamp);
- if (0 != offset.rel_value)
+ if (0 != offset.rel_value_us)
{
/* somehow run early, delay more */
flood_task =
@@ -791,8 +792,8 @@ update_flood_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
current_timestamp = next_timestamp;
next_timestamp =
GNUNET_TIME_absolute_add (current_timestamp, gnunet_nse_interval);
- if ((current_timestamp.abs_value ==
- GNUNET_TIME_absolute_ntoh (next_message.timestamp).abs_value) &&
+ if ((current_timestamp.abs_value_us ==
+ GNUNET_TIME_absolute_ntoh (next_message.timestamp).abs_value_us) &&
(get_matching_bits (current_timestamp, &my_identity) <
ntohl(next_message.matching_bits)))
{
@@ -1038,7 +1039,7 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer,
{
uint64_t t;
- t = GNUNET_TIME_absolute_get().abs_value;
+ t = GNUNET_TIME_absolute_get().abs_value_us;
GNUNET_TESTBED_LOGGER_write (lh, &t, sizeof (uint64_t));
}
#endif
@@ -1078,12 +1079,12 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer,
#endif
ts = GNUNET_TIME_absolute_ntoh (incoming_flood->timestamp);
- if (ts.abs_value == current_timestamp.abs_value)
+ if (ts.abs_value_us == current_timestamp.abs_value_us)
idx = estimate_index;
- else if (ts.abs_value ==
- current_timestamp.abs_value - gnunet_nse_interval.rel_value)
+ else if (ts.abs_value_us ==
+ current_timestamp.abs_value_us - gnunet_nse_interval.rel_value_us)
idx = (estimate_index + HISTORY_SIZE - 1) % HISTORY_SIZE;
- else if (ts.abs_value == next_timestamp.abs_value)
+ else if (ts.abs_value_us == next_timestamp.abs_value_us)
{
if (matching_bits <= ntohl (next_message.matching_bits))
return GNUNET_OK; /* ignore, simply too early/late */
@@ -1359,9 +1360,9 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server,
memcmp (&my_identity, identity,
sizeof (struct GNUNET_PeerIdentity)));
now = GNUNET_TIME_absolute_get ();
- current_timestamp.abs_value =
- (now.abs_value / gnunet_nse_interval.rel_value) *
- gnunet_nse_interval.rel_value;
+ current_timestamp.abs_value_us =
+ (now.abs_value_us / gnunet_nse_interval.rel_value_us) *
+ gnunet_nse_interval.rel_value_us;
next_timestamp =
GNUNET_TIME_absolute_add (current_timestamp, gnunet_nse_interval);
estimate_index = HISTORY_SIZE - 1;
@@ -1369,8 +1370,8 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server,
if (GNUNET_YES == check_proof_of_work (&my_public_key, my_proof))
{
int idx = (estimate_index + HISTORY_SIZE - 1) % HISTORY_SIZE;
- prev_time.abs_value =
- current_timestamp.abs_value - gnunet_nse_interval.rel_value;
+ prev_time.abs_value_us =
+ current_timestamp.abs_value_us - gnunet_nse_interval.rel_value_us;
setup_flood_message (idx, prev_time);
setup_flood_message (estimate_index, current_timestamp);
estimate_count++;
diff --git a/src/nse/nse_api.c b/src/nse/nse_api.c
index 8f4486287..211071c0d 100644
--- a/src/nse/nse_api.c
+++ b/src/nse/nse_api.c
@@ -24,14 +24,11 @@
* @author Nathan Evans
*/
#include "platform.h"
-#include "gnunet_client_lib.h"
#include "gnunet_constants.h"
-#include "gnunet_container_lib.h"
#include "gnunet_arm_service.h"
#include "gnunet_hello_lib.h"
#include "gnunet_protocols.h"
-#include "gnunet_server_lib.h"
-#include "gnunet_time_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_nse_service.h"
#include "nse.h"
@@ -150,8 +147,9 @@ reschedule_connect (struct GNUNET_NSE_Handle *h)
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Scheduling task to reconnect to nse service in %llu ms.\n",
- h->reconnect_delay.rel_value);
+ "Scheduling task to reconnect to nse 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);
diff --git a/src/nse/perf_kdf.c b/src/nse/perf_kdf.c
index fbc846ac2..89ddada81 100644
--- a/src/nse/perf_kdf.c
+++ b/src/nse/perf_kdf.c
@@ -79,7 +79,7 @@ main (int argc, char *argv[])
GAUGER ("NSE", "Proof-of-work hashing",
1024 / (1 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value), "hashes/s");
+ (start).rel_value_us / 1000LL), "hashes/ms");
return 0;
}
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index 6be98879f..fc953ad3e 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -209,7 +209,7 @@ discard_expired (void *cls, const struct GNUNET_HELLO_Address *address,
{
const struct GNUNET_TIME_Absolute *now = cls;
- if (now->abs_value > expiration.abs_value)
+ if (now->abs_value_us > expiration.abs_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Removing expired address of transport `%s'\n"),
@@ -728,7 +728,7 @@ update_hello (const struct GNUNET_PeerIdentity *peer,
{
mrg = GNUNET_HELLO_merge ((*dest), hello);
delta = GNUNET_HELLO_equals (mrg, (*dest), GNUNET_TIME_absolute_get ());
- if (delta.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
+ if (delta.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
{
/* no differences, just ignore the update */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No change in %s HELLO for `%s'\n",
diff --git a/src/pt/test_gns_vpn.c b/src/pt/test_gns_vpn.c
index d30c64c2f..2ba72bba9 100644
--- a/src/pt/test_gns_vpn.c
+++ b/src/pt/test_gns_vpn.c
@@ -393,7 +393,7 @@ run (void *cls,
}
host_key = GNUNET_CRYPTO_ecc_key_create_from_file (zone_keyfile);
- rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value;
+ rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
GNUNET_asprintf (&rd_string, "6 %s %s", (char*)&peername, "www.gads.");
GNUNET_assert (GNUNET_OK == GNUNET_NAMESTORE_string_to_value (GNUNET_GNS_RECORD_VPN,
rd_string,
diff --git a/src/regex/gnunet-daemon-regexprofiler.c b/src/regex/gnunet-daemon-regexprofiler.c
index d4c9cb7cb..86f7d451b 100644
--- a/src/regex/gnunet-daemon-regexprofiler.c
+++ b/src/regex/gnunet-daemon-regexprofiler.c
@@ -179,10 +179,10 @@ reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
}
random_delay =
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,
GNUNET_CRYPTO_random_u32 (
GNUNET_CRYPTO_QUALITY_WEAK,
- reannounce_period_max.rel_value));
+ reannounce_period_max.rel_value_us));
reannounce_task = GNUNET_SCHEDULER_add_delayed (random_delay,
&reannounce_regex, cls);
}
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c
index 317f65d8d..681ade880 100644
--- a/src/regex/plugin_block_regex.c
+++ b/src/regex/plugin_block_regex.c
@@ -177,7 +177,7 @@ evaluate_block_regex_accept (void *cls, enum GNUNET_BLOCK_Type type,
GNUNET_break_op(0);
return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
}
- if (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (rba->expiration_time)).rel_value)
+ if (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (rba->expiration_time)).rel_value_us)
{
/* technically invalid, but can happen without an error, so
we're nice by reporting it as a 'duplicate' */
diff --git a/src/sysmon/gnunet-service-sysmon.c b/src/sysmon/gnunet-service-sysmon.c
index b5fc46ac8..0aa96b7f7 100644
--- a/src/sysmon/gnunet-service-sysmon.c
+++ b/src/sysmon/gnunet-service-sysmon.c
@@ -277,7 +277,7 @@ update_uptime (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (GNUNET_YES == first_run)
first_run = GNUNET_NO;
else
- sp->num_val += sp->interval.rel_value / 1000;
+ sp->num_val += sp->interval.rel_value_us / 1000LL / 1000LL;
put_property (sp);
}
@@ -548,11 +548,13 @@ load_property (void *cls,
}
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded property `%s': %s, %s, interval %llu\n",
- (NULL != sp->desc) ? sp->desc: "<undefined>",
- (t_continous == sp->type) ? "continious" : "static",
- (v_numeric == sp->value_type) ? "numeric" : "string",
- sp->interval.rel_value);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Loaded property `%s': %s, %s, interval %s\n",
+ (NULL != sp->desc) ? sp->desc: "<undefined>",
+ (t_continous == sp->type) ? "continious" : "static",
+ (v_numeric == sp->value_type) ? "numeric" : "string",
+ GNUNET_STRINGS_relative_time_to_string (sp->interval,
+ GNUNET_YES));
GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
@@ -615,7 +617,7 @@ load_default_properties (void)
sp->desc = GNUNET_strdup ("GNUnet startup time");
sp->type = t_static;
sp->value_type = v_numeric;
- sp->num_val = (uint64_t) GNUNET_TIME_absolute_get().abs_value;
+ sp->num_val = (uint64_t) GNUNET_TIME_absolute_get().abs_value_us;
GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
diff --git a/src/testbed/gnunet-service-testbed_cpustatus.c b/src/testbed/gnunet-service-testbed_cpustatus.c
index 8145410fb..4b61a039c 100644
--- a/src/testbed/gnunet-service-testbed_cpustatus.c
+++ b/src/testbed/gnunet-service-testbed_cpustatus.c
@@ -527,7 +527,7 @@ updateAgedLoad ()
age = GNUNET_TIME_absolute_get_duration (lastCall);
if ( (agedCPULoad == -1)
- || (age.rel_value > 500) )
+ || (age.rel_value_us > 500000) )
{
/* use smoothing, but do NOT update lastRet at frequencies higher
than 500ms; this makes the smoothing (mostly) independent from
@@ -667,7 +667,7 @@ sample_load_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
nproc = 0;
#endif
now = GNUNET_TIME_absolute_get ();
- nbs = GNUNET_asprintf (&str, "%llu %d %d %u %u\n", now.abs_value / 1000,
+ nbs = GNUNET_asprintf (&str, "%llu %d %d %u %u\n", now.abs_value_us / 1000LL / 1000LL,
ld_cpu, ld_disk, mem_usage, nproc);
if (0 < nbs)
{
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index bb6197e9a..cd805dca1 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -1695,12 +1695,12 @@ decide_npoc (struct GNUNET_TESTBED_Host *h)
}
GNUNET_assert (nvals >= h->num_parallel_connects);
avg = GNUNET_TIME_relative_divide (avg, nvals);
- GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value != avg.rel_value);
- sd = GNUNET_TESTBED_SD_deviation_factor_ (h->poc_sd, (unsigned int) avg.rel_value);
+ GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != avg.rel_value_us);
+ sd = GNUNET_TESTBED_SD_deviation_factor_ (h->poc_sd, (unsigned int) avg.rel_value_us);
if ( (sd <= 5) ||
(0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
h->num_parallel_connects)) )
- GNUNET_TESTBED_SD_add_data_ (h->poc_sd, (unsigned int) avg.rel_value);
+ GNUNET_TESTBED_SD_add_data_ (h->poc_sd, (unsigned int) avg.rel_value_us);
if (GNUNET_SYSERR == sd)
{
GNUNET_TESTBED_set_num_parallel_overlay_connects_ (h,
@@ -1798,7 +1798,7 @@ GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Host *h,
return;
slot = &h->tslots[index];
slot->nvals++;
- if (GNUNET_TIME_UNIT_ZERO.rel_value == slot->time.rel_value)
+ if (GNUNET_TIME_UNIT_ZERO.rel_value_us == slot->time.rel_value_us)
{
slot->time = time;
h->tslots_filled++;
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c
index 61ee308f8..6687ee02a 100644
--- a/src/topology/gnunet-daemon-topology.c
+++ b/src/topology/gnunet-daemon-topology.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2007, 2008, 2009, 2010 Christian Grothoff (and other contributing authors)
+ (C) 2007-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
@@ -362,7 +362,7 @@ attempt_connect (struct Peer *pos)
return;
if (GNUNET_OK != is_connection_allowed (pos))
return;
- if (GNUNET_TIME_absolute_get_remaining (pos->greylisted_until).rel_value > 0)
+ if (GNUNET_TIME_absolute_get_remaining (pos->greylisted_until).rel_value_us > 0)
return;
if (GNUNET_YES == pos->is_friend)
rem = GREYLIST_AFTER_ATTEMPT_FRIEND;
@@ -407,7 +407,7 @@ do_attempt_connect (void *cls,
if (GNUNET_YES == pos->is_connected)
return;
delay = GNUNET_TIME_absolute_get_remaining (next_connect_attempt);
- if (delay.rel_value > 0)
+ if (delay.rel_value_us > 0)
{
pos->attempt_connect_task = GNUNET_SCHEDULER_add_delayed (delay,
&do_attempt_connect,
@@ -450,7 +450,7 @@ remove_from_greylist (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
pos->greylist_clean_task = GNUNET_SCHEDULER_NO_TASK;
rem = GNUNET_TIME_absolute_get_remaining (pos->greylisted_until);
- if (rem.rel_value == 0)
+ if (0 == rem.rel_value_us)
{
schedule_attempt_connect (pos);
}
@@ -580,7 +580,7 @@ find_advertisable_hello (void *cls, const struct GNUNET_HashCode * pid, void *va
if (pos->hello == NULL)
return GNUNET_YES;
rst_time = GNUNET_TIME_absolute_get_remaining (pos->filter_expiration);
- if (0 == rst_time.rel_value)
+ if (0 == rst_time.rel_value_us)
{
/* time to discard... */
GNUNET_CONTAINER_bloomfilter_free (pos->filter);
@@ -631,7 +631,7 @@ schedule_next_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
return;
next_want = GNUNET_HELLO_size (fah.result->hello);
delay = GNUNET_TIME_absolute_get_remaining (pl->next_hello_allowed);
- if (delay.rel_value == 0)
+ if (0 == delay.rel_value_us)
{
/* now! */
pl->hello_req =
@@ -708,7 +708,7 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer)
else
{
GNUNET_assert (GNUNET_NO == pos->is_connected);
- pos->greylisted_until.abs_value = 0; /* remove greylisting */
+ pos->greylisted_until.abs_value_us = 0; /* remove greylisting */
}
pos->is_connected = GNUNET_YES;
pos->connect_attempts = 0; /* re-set back-off factor */
@@ -870,7 +870,7 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello)
else if (peer->hello != NULL)
{
dt = GNUNET_HELLO_equals (peer->hello, hello, GNUNET_TIME_absolute_get ());
- if (dt.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
+ if (dt.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
return; /* nothing new here */
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -940,7 +940,7 @@ process_peer (void *cls, const struct GNUNET_PeerIdentity *peer,
if ((GNUNET_NO == pos->is_connected) && (GNUNET_NO == pos->is_friend) &&
(0 ==
GNUNET_TIME_absolute_get_remaining (pos->
- greylisted_until).rel_value))
+ greylisted_until).rel_value_us))
free_peer (NULL, &pos->pid.hashPubKey, pos);
}
return;
@@ -956,7 +956,7 @@ process_peer (void *cls, const struct GNUNET_PeerIdentity *peer,
GNUNET_i2s (peer));
return;
}
- if (GNUNET_TIME_absolute_get_remaining (pos->greylisted_until).rel_value > 0)
+ if (GNUNET_TIME_absolute_get_remaining (pos->greylisted_until).rel_value_us > 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Already tried peer `%s' recently\n",
GNUNET_i2s (peer));
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;
}
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c
index 60cb50529..5caaec03c 100644
--- a/src/util/bandwidth.c
+++ b/src/util/bandwidth.c
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2010 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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -83,9 +83,9 @@ GNUNET_BANDWIDTH_value_get_available_until (struct GNUNET_BANDWIDTH_Value32NBO
b = ntohl (bps.value__);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Bandwidth has %llu bytes available until deadline in %s\n",
- (unsigned long long) ((b * deadline.rel_value + 500LL) / 1000LL),
+ (unsigned long long) ((b * deadline.rel_value_us + 500000LL) / 1000000LL),
GNUNET_STRINGS_relative_time_to_string (deadline, GNUNET_YES));
- return (b * deadline.rel_value + 500LL) / 1000LL;
+ return (b * deadline.rel_value_us + 500000LL) / 1000000LL;
}
@@ -105,16 +105,17 @@ GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps,
struct GNUNET_TIME_Relative ret;
b = ntohl (bps.value__);
- if (b == 0)
+ if (0 == b)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Bandwidth suggests delay of infinity (zero bandwidth)\n");
return GNUNET_TIME_UNIT_FOREVER_REL;
}
- ret.rel_value = size * 1000LL / b;
+ ret.rel_value_us = size * 1000LL * 1000LL / b;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Bandwidth suggests delay of %llu ms for %llu bytes of traffic\n",
- (unsigned long long) ret.rel_value, (unsigned long long) size);
+ "Bandwidth suggests delay of %s for %llu bytes of traffic\n",
+ GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES),
+ (unsigned long long) size);
return ret;
}
@@ -158,16 +159,17 @@ static void
update_tracker (struct GNUNET_BANDWIDTH_Tracker *av)
{
struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Relative delta;
uint64_t delta_time;
uint64_t delta_avail;
uint64_t left_bytes;
uint64_t max_carry;
now = GNUNET_TIME_absolute_get ();
- delta_time = now.abs_value - av->last_update__.abs_value;
+ delta_time = now.abs_value_us - av->last_update__.abs_value_us;
delta_avail =
(delta_time * ((unsigned long long) av->available_bytes_per_s__) +
- 500LL) / 1000LL;
+ 500000LL) / 1000000LL;
av->consumption_since_last_update__ -= delta_avail;
av->last_update__ = now;
if (av->consumption_since_last_update__ < 0)
@@ -181,10 +183,11 @@ update_tracker (struct GNUNET_BANDWIDTH_Tracker *av)
else
av->consumption_since_last_update__ = -max_carry;
}
+ delta.rel_value_us = delta_time;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Tracker %p updated, have %u Bps, last update was %llu ms ago\n", av,
+ "Tracker %p updated, have %u Bps, last update was %s ago\n", av,
(unsigned int) av->available_bytes_per_s__,
- (unsigned long long) delta_time);
+ GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_YES));
}
@@ -251,22 +254,26 @@ GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av,
if (av->available_bytes_per_s__ == 0)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay is infinity\n", av);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Tracker %p delay is infinity\n", av);
return GNUNET_TIME_UNIT_FOREVER_REL;
}
update_tracker (av);
bytes_needed = size + av->consumption_since_last_update__;
if (bytes_needed <= 0)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay for %u bytes is zero\n", av,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Tracker %p delay for %u bytes is zero\n", av,
(unsigned int) size);
return GNUNET_TIME_UNIT_ZERO;
}
- ret.rel_value =
- (1000LL * bytes_needed) /
+ ret.rel_value_us =
+ (1000LL * 1000LL * bytes_needed) /
(unsigned long long) av->available_bytes_per_s__;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay for %u bytes is %llu ms\n",
- av, (unsigned int) size, (unsigned long long) ret.rel_value);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Tracker %p delay for %u bytes is %s\n",
+ av, (unsigned int) size,
+ GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES));
return ret;
}
@@ -293,7 +300,7 @@ GNUNET_BANDWIDTH_tracker_get_available (struct GNUNET_BANDWIDTH_Tracker * av)
(av->last_update__));
used = av->consumption_since_last_update__;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Tracker %p available bandwidth is %lld bytes\n", av,
+ "Tracker %p available bandwidth is %lld bytes\n", av,
(long long) (int64_t) (avail - used));
return (int64_t) (avail - used);
}
@@ -314,7 +321,8 @@ GNUNET_BANDWIDTH_tracker_update_quota (struct GNUNET_BANDWIDTH_Tracker *av,
uint32_t new_limit;
new_limit = ntohl (bytes_per_second_limit.value__);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p bandwidth changed to %u Bps\n", av,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Tracker %p bandwidth changed to %u Bps\n", av,
(unsigned int) new_limit);
update_tracker (av);
old_limit = av->available_bytes_per_s__;
diff --git a/src/util/client.c b/src/util/client.c
index 811bb8e12..6c5e93ce4 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2006, 2008, 2009, 2012 Christian Grothoff (and other contributing authors)
+ (C) 2001-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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -409,7 +409,7 @@ GNUNET_CLIENT_connect (const char *service_name,
cfg))
return NULL;
connection = do_connect (service_name, cfg, 0);
- client = GNUNET_malloc (sizeof (struct GNUNET_CLIENT_Connection));
+ client = GNUNET_new (struct GNUNET_CLIENT_Connection);
client->first_message = GNUNET_YES;
client->attempts = 1;
client->connection = connection;
@@ -536,7 +536,7 @@ receive_helper (void *cls, const void *buf, size_t available,
check_complete (client);
/* check for timeout */
remaining = GNUNET_TIME_absolute_get_remaining (client->receive_timeout);
- if (0 == remaining.rel_value)
+ if (0 == remaining.rel_value_us)
{
/* signal timeout! */
if (NULL != client->receiver_handler)
@@ -1094,9 +1094,9 @@ client_notify (void *cls, size_t size, void *buf)
if (NULL == buf)
{
delay = GNUNET_TIME_absolute_get_remaining (th->timeout);
- delay.rel_value /= 2;
+ delay.rel_value_us /= 2;
if ((GNUNET_YES != th->auto_retry) || (0 == --th->attempts_left) ||
- (delay.rel_value < 1)||
+ (delay.rel_value_us < 1)||
(0 != (GNUNET_SCHEDULER_get_reason() & GNUNET_SCHEDULER_REASON_SHUTDOWN)))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index 5b355b2e1..8f1c8e876 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2006, 2008, 2009 Christian Grothoff (and other contributing authors)
+ (C) 2006-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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -26,17 +26,15 @@
*/
#include "platform.h"
#include "gnunet_common.h"
-#include "gnunet_crypto_lib.h"
-#include "gnunet_strings_lib.h"
-#include "gnunet_time_lib.h"
-
+#include "gnunet_util_lib.h"
#include <regex.h>
+
/**
* After how many milliseconds do we always print
* that "message X was repeated N times"? Use 12h.
*/
-#define BULK_DELAY_THRESHOLD (12 * 60 * 60 * 1000)
+#define BULK_DELAY_THRESHOLD (12 * 60 * 60 * 1000LL * 1000LL)
/**
* After how many repetitions do we always print
@@ -800,7 +798,7 @@ flush_bulk (const char *datestr)
char *last;
const char *ft;
- if ((last_bulk_time.abs_value == 0) || (last_bulk_repeat == 0))
+ if ((0 == last_bulk_time.abs_value_us) || (0 == last_bulk_repeat))
return;
rev = 0;
last = memchr (last_bulk, '\0', BULK_TRACK_SIZE);
@@ -951,12 +949,13 @@ mylog (enum GNUNET_ErrorType kind, const char *comp, const char *message,
if (NULL != tmptr)
(void) setup_log_file (tmptr);
if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) &&
- (last_bulk_time.abs_value != 0) &&
+ (0 != last_bulk_time.abs_value_us) &&
(0 == strncmp (buf, last_bulk, sizeof (last_bulk))))
{
last_bulk_repeat++;
- if ((GNUNET_TIME_absolute_get_duration (last_bulk_time).rel_value >
- BULK_DELAY_THRESHOLD) || (last_bulk_repeat > BULK_REPEAT_THRESHOLD))
+ if ( (GNUNET_TIME_absolute_get_duration (last_bulk_time).rel_value_us >
+ BULK_DELAY_THRESHOLD) ||
+ (last_bulk_repeat > BULK_REPEAT_THRESHOLD) )
flush_bulk (date);
return;
}
diff --git a/src/util/connection.c b/src/util/connection.c
index ea35b04e1..bdfcd1add 100644
--- a/src/util/connection.c
+++ b/src/util/connection.c
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2009, 2012 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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -33,11 +33,8 @@
#include "platform.h"
#include "gnunet_common.h"
-#include "gnunet_connection_lib.h"
-#include "gnunet_container_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_resolver_service.h"
-#include "gnunet_scheduler_lib.h"
-#include "gnunet_server_lib.h"
#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
@@ -304,7 +301,7 @@ GNUNET_CONNECTION_create_from_existing (struct GNUNET_NETWORK_Handle *osSocket)
{
struct GNUNET_CONNECTION_Handle *connection;
- connection = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle));
+ connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->sock = osSocket;
@@ -362,7 +359,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access,
if ((AF_INET6 == sa->sa_family) && (IN6_IS_ADDR_V4MAPPED (&v6->sin6_addr)))
{
/* convert to V4 address */
- v4 = GNUNET_malloc (sizeof (struct sockaddr_in));
+ v4 = GNUNET_new (struct sockaddr_in);
memset (v4, 0, sizeof (struct sockaddr_in));
v4->sin_family = AF_INET;
#if HAVE_SOCKADDR_IN_SIN_LEN
@@ -432,7 +429,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access,
GNUNET_free (uaddr);
return NULL;
}
- connection = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle));
+ connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->addr = uaddr;
@@ -800,7 +797,7 @@ GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle
struct GNUNET_CONNECTION_Handle *connection;
GNUNET_assert (0 < strlen (hostname)); /* sanity check */
- connection = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle));
+ connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
connection->cfg = cfg;
connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
@@ -834,7 +831,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct
size_t slen;
GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
- un = GNUNET_malloc (sizeof (struct sockaddr_un));
+ un = GNUNET_new (struct sockaddr_un);
un->sun_family = AF_UNIX;
slen = strlen (unixpath);
if (slen >= sizeof (un->sun_path))
@@ -848,7 +845,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct
#if LINUX
un->sun_path[0] = '\0';
#endif
- connection = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle));
+ connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
connection->cfg = cfg;
connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
@@ -1042,9 +1039,9 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Receive from `%s' encounters error: timeout (%p)\n",
+ "Receive from `%s' encounters error: timeout (%s, %p)\n",
GNUNET_a2s (connection->addr, connection->addrlen),
- GNUNET_TIME_absolute_get_duration (connection->receive_timeout).rel_value,
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (connection->receive_timeout), GNUNET_YES),
connection);
signal_receive_timeout (connection);
return;
diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c
index 507ecf661..cab13ae57 100644
--- a/src/util/gnunet-service-resolver.c
+++ b/src/util/gnunet-service-resolver.c
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2007, 2008, 2009, 2012 Christian Grothoff (and other contributing authors)
+ (C) 2007-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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -217,8 +217,8 @@ get_ip_as_string (struct GNUNET_SERVER_Client *client,
(0 != memcmp (pos->ip, ip, ip_len))) )
{
next = pos->next;
- if (GNUNET_TIME_absolute_get_duration (pos->last_request).rel_value <
- 60 * 60 * 1000)
+ if (GNUNET_TIME_absolute_get_duration (pos->last_request).rel_value_us <
+ 60 * 60 * 1000 * 1000LL)
{
GNUNET_CONTAINER_DLL_remove (cache_head,
cache_tail,
@@ -231,8 +231,8 @@ get_ip_as_string (struct GNUNET_SERVER_Client *client,
if (pos != NULL)
{
pos->last_request = now;
- if (GNUNET_TIME_absolute_get_duration (pos->last_request).rel_value <
- 60 * 60 * 1000)
+ if (GNUNET_TIME_absolute_get_duration (pos->last_request).rel_value_us <
+ 60 * 60 * 1000 * 1000LL)
{
GNUNET_free_non_null (pos->addr);
pos->addr = NULL;
diff --git a/src/util/load.c b/src/util/load.c
index 146e85095..06e284c4c 100644
--- a/src/util/load.c
+++ b/src/util/load.c
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2010 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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -24,7 +24,7 @@
* @author Christian Grothoff
*/
#include "platform.h"
-#include "gnunet_load_lib.h"
+#include "gnunet_util_lib.h"
#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
@@ -87,18 +87,18 @@ internal_update (struct GNUNET_LOAD_Value *load)
struct GNUNET_TIME_Relative delta;
unsigned int n;
- if (load->autodecline.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
+ if (load->autodecline.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
return;
delta = GNUNET_TIME_absolute_get_duration (load->last_update);
- if (delta.rel_value < load->autodecline.rel_value)
+ if (delta.rel_value_us < load->autodecline.rel_value_us)
return;
- if (load->autodecline.rel_value == 0)
+ if (0 == load->autodecline.rel_value_us)
{
load->runavg_delay = 0.0;
load->load = 0;
return;
}
- n = delta.rel_value / load->autodecline.rel_value;
+ n = delta.rel_value_us / load->autodecline.rel_value_us;
if (n > 16)
{
load->runavg_delay = 0.0;
@@ -126,7 +126,7 @@ GNUNET_LOAD_value_init (struct GNUNET_TIME_Relative autodecline)
{
struct GNUNET_LOAD_Value *ret;
- ret = GNUNET_malloc (sizeof (struct GNUNET_LOAD_Value));
+ ret = GNUNET_new (struct GNUNET_LOAD_Value);
ret->autodecline = autodecline;
ret->last_update = GNUNET_TIME_absolute_get ();
return ret;
diff --git a/src/util/network.c b/src/util/network.c
index 7a51a8b67..8398b9fab 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2009, 2012 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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -1332,7 +1332,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
}
if ((nfds == 0) &&
- (timeout.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
+ (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
#ifdef MINGW
&& handles == 0
#endif
@@ -1345,25 +1345,26 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
"select");
}
#ifndef MINGW
- tv.tv_sec = timeout.rel_value / GNUNET_TIME_UNIT_SECONDS.rel_value;
+ tv.tv_sec = timeout.rel_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us;
tv.tv_usec =
- 1000 * (timeout.rel_value -
- (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value));
- return select (nfds, (rfds != NULL) ? &rfds->sds : NULL,
- (wfds != NULL) ? &wfds->sds : NULL,
- (efds != NULL) ? &efds->sds : NULL,
- (timeout.rel_value ==
- GNUNET_TIME_UNIT_FOREVER_REL.rel_value) ? NULL : &tv);
+ (timeout.rel_value_us -
+ (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us));
+ return select (nfds,
+ (NULL != rfds) ? &rfds->sds : NULL,
+ (NULL != wfds) ? &wfds->sds : NULL,
+ (NULL != efds) ? &efds->sds : NULL,
+ (timeout.rel_value_us ==
+ GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) ? NULL : &tv);
#else
#define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set))
/* calculate how long we need to wait in milliseconds */
- if (timeout.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
+ if (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
ms_total = INFINITE;
else
{
- ms_total = timeout.rel_value / GNUNET_TIME_UNIT_MILLISECONDS.rel_value;
- if (timeout.rel_value / GNUNET_TIME_UNIT_MILLISECONDS.rel_value > 0xFFFFFFFFLL - 1)
+ ms_total = timeout.rel_value_us / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us;
+ if (timeout.rel_value_us / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us > 0xFFFFFFFFLL - 1)
{
GNUNET_break (0);
ms_total = 0xFFFFFFFF - 1;
@@ -1376,7 +1377,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
return 0;
}
- if (select_thread == NULL)
+ if (NULL == select_thread)
{
SOCKET select_listening_socket = -1;
struct sockaddr_in s_in;
@@ -1742,15 +1743,16 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
if (nfds > 0)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Adding the socket event to the array as %d\n", nhandles);
+ "Adding the socket event to the array as %d\n",
+ nhandles);
handle_array[nhandles++] = select_finished_event;
- if (timeout.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
+ if (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
sp.tv = NULL;
else
{
- select_timeout.tv_sec = timeout.rel_value / GNUNET_TIME_UNIT_SECONDS.rel_value;
- select_timeout.tv_usec = 1000 * (timeout.rel_value -
- (select_timeout.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value));
+ select_timeout.tv_sec = timeout.rel_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us;
+ select_timeout.tv_usec =(timeout.rel_value_us -
+ (select_timeout.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us));
sp.tv = &select_timeout;
}
FD_SET (select_wakeup_socket, &aread);
diff --git a/src/util/perf_crypto_hash.c b/src/util/perf_crypto_hash.c
index 930e99844..affd4a2d5 100644
--- a/src/util/perf_crypto_hash.c
+++ b/src/util/perf_crypto_hash.c
@@ -53,9 +53,9 @@ main (int argc, char *argv[])
GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
GNUNET_YES));
GAUGER ("UTIL", "Cryptographic hashing",
- 1024 * 64 * 1024 / (1 +
- GNUNET_TIME_absolute_get_duration
- (start).rel_value), "kb/s");
+ 64 * 1024 / (1 +
+ GNUNET_TIME_absolute_get_duration
+ (start).rel_value_us / 1000LL), "kb/ms");
return 0;
}
diff --git a/src/util/perf_malloc.c b/src/util/perf_malloc.c
index 31f08dff0..f25529269 100644
--- a/src/util/perf_malloc.c
+++ b/src/util/perf_malloc.c
@@ -53,13 +53,13 @@ main (int argc, char *argv[])
start = GNUNET_TIME_absolute_get ();
kb = perfMalloc ();
- printf ("Malloc perf took %llu ms\n",
- (unsigned long long)
- GNUNET_TIME_absolute_get_duration (start).rel_value);
+ printf ("Malloc perf took %s\n",
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
+ GNUNET_YES));
GAUGER ("UTIL", "Allocation",
kb / 1024 / (1 +
- GNUNET_TIME_absolute_get_duration
- (start).rel_value), "kb/s");
+ GNUNET_TIME_absolute_get_duration
+ (start).rel_value_us / 1000LL), "kb/ms");
return 0;
}
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index 7acc0f87f..9a2228da0 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2009, 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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -24,13 +24,9 @@
* @author Christian Grothoff
*/
#include "platform.h"
-#include "gnunet_getopt_lib.h"
-#include "gnunet_os_lib.h"
-#include "gnunet_client_lib.h"
-#include "gnunet_container_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_resolver_service.h"
-#include "gnunet_server_lib.h"
#include "resolver.h"
#define LOG(kind,...) GNUNET_log_from (kind, "resolver-api", __VA_ARGS__)
@@ -703,8 +699,8 @@ reconnect ()
}
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Will try to connect to DNS service in %llu ms\n",
- (unsigned long long) backoff.rel_value);
+ "Will try to connect to DNS service in %s\n",
+ GNUNET_STRINGS_relative_time_to_string (backoff, GNUNET_YES));
GNUNET_assert (NULL != resolver_cfg);
r_task = GNUNET_SCHEDULER_add_delayed (backoff, &reconnect_task, NULL);
backoff = GNUNET_TIME_STD_BACKOFF (backoff);
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 23f683808..5b90d7e4f 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet
- (C) 2009, 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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -300,7 +300,7 @@ update_sets (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws,
if (pos != NULL)
{
to = GNUNET_TIME_absolute_get_difference (now, pos->timeout);
- if (timeout->rel_value > to.rel_value)
+ if (timeout->rel_value_us > to.rel_value_us)
*timeout = to;
if (pos->reason != 0)
*timeout = GNUNET_TIME_UNIT_ZERO;
@@ -308,10 +308,10 @@ update_sets (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws,
pos = pending;
while (pos != NULL)
{
- if (pos->timeout.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
+ if (pos->timeout.abs_value_us != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
{
to = GNUNET_TIME_absolute_get_difference (now, pos->timeout);
- if (timeout->rel_value > to.rel_value)
+ if (timeout->rel_value_us > to.rel_value_us)
*timeout = to;
}
if (pos->read_fd != -1)
@@ -373,7 +373,7 @@ is_ready (struct Task *task, struct GNUNET_TIME_Absolute now,
enum GNUNET_SCHEDULER_Reason reason;
reason = task->reason;
- if (now.abs_value >= task->timeout.abs_value)
+ if (now.abs_value_us >= task->timeout.abs_value_us)
reason |= GNUNET_SCHEDULER_REASON_TIMEOUT;
if ((0 == (reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
(((task->read_fd != -1) &&
@@ -433,7 +433,7 @@ check_ready (const struct GNUNET_NETWORK_FDSet *rs,
while (pos != NULL)
{
next = pos->next;
- if (now.abs_value >= pos->timeout.abs_value)
+ if (now.abs_value_us >= pos->timeout.abs_value_us)
pos->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT;
if (0 == pos->reason)
break;
@@ -569,8 +569,8 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws)
current_lifeness = pos->lifeness;
active_task = pos;
#if PROFILE_DELAYS
- if (GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value >
- DELAY_THRESHOLD.rel_value)
+ if (GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value_us >
+ DELAY_THRESHOLD.rel_value_us)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Task %llu took %s to be scheduled\n",
@@ -777,7 +777,7 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
GNUNET_abort ();
break;
}
- if ((ret == 0) && (timeout.rel_value == 0) && (busy_wait_warning > 16))
+ if ((0 == ret) && (0 == timeout.rel_value_us) && (busy_wait_warning > 16))
{
LOG (GNUNET_ERROR_TYPE_WARNING, _("Looks like we're busy waiting...\n"));
sleep (1); /* mitigate */
@@ -1091,7 +1091,7 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay,
prev = pending_timeout_last;
if (prev != NULL)
{
- if (prev->timeout.abs_value > t->timeout.abs_value)
+ if (prev->timeout.abs_value_us > t->timeout.abs_value_us)
prev = NULL;
else
pos = prev->next; /* heuristic success! */
@@ -1102,8 +1102,8 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay,
pos = pending_timeout;
}
while ((pos != NULL) &&
- ((pos->timeout.abs_value <= t->timeout.abs_value) ||
- (pos->reason != 0)))
+ ((pos->timeout.abs_value_us <= t->timeout.abs_value_us) ||
+ (0 != pos->reason)))
{
prev = pos;
pos = pos->next;
diff --git a/src/util/server.c b/src/util/server.c
index b2264479a..05463e1cb 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2009, 2012 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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -1032,8 +1032,8 @@ process_mst (struct GNUNET_SERVER_Client *client, int ret)
if (GNUNET_OK == ret)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Server re-enters receive loop, timeout: %llu.\n",
- client->idle_timeout.rel_value);
+ "Server re-enters receive loop, timeout: %s.\n",
+ GNUNET_STRINGS_relative_time_to_string (client->idle_timeout, GNUNET_YES));
client->receive_pending = GNUNET_YES;
GNUNET_CONNECTION_receive (client->connection,
GNUNET_SERVER_MAX_MESSAGE_SIZE - 1,
@@ -1094,7 +1094,7 @@ process_incoming (void *cls, const void *buf, size_t available,
if ((NULL == buf) && (0 == available) && (NULL == addr) && (0 == errCode) &&
(GNUNET_YES != client->shutdown_now) && (NULL != server) &&
(GNUNET_YES == GNUNET_CONNECTION_check (client->connection)) &&
- (end.abs_value > now.abs_value))
+ (end.abs_value_us > now.abs_value_us))
{
/* wait longer, timeout changed (i.e. due to us sending) */
LOG (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/util/speedup.c b/src/util/speedup.c
index 6cb8a4e05..2482decea 100644
--- a/src/util/speedup.c
+++ b/src/util/speedup.c
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2006, 2009 Christian Grothoff (and other contributing authors)
+ (C) 2011-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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -24,8 +24,7 @@
* @brief functions to speedup peer execution by manipulation system time
*/
#include "platform.h"
-#include "gnunet_time_lib.h"
-#include "gnunet_scheduler_lib.h"
+#include "gnunet_util_lib.h"
#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
@@ -45,10 +44,11 @@ do_speedup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
speedup_task = GNUNET_SCHEDULER_NO_TASK;
if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
return;
- current_offset += delta.rel_value;
+ current_offset += delta.rel_value_us;
GNUNET_TIME_set_offset (current_offset);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Speeding up execution time by %llu ms\n", delta.rel_value);
+ "Speeding up execution time by %s\n",
+ GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_NO));
speedup_task = GNUNET_SCHEDULER_add_delayed (interval, &do_speedup, NULL);
}
@@ -67,15 +67,18 @@ GNUNET_SPEEDUP_start_ (const struct GNUNET_CONFIGURATION_Handle *cfg)
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, "testing", "SPEEDUP_DELTA", &delta))
return GNUNET_SYSERR;
- if ((0 == interval.rel_value) || (0 == delta.rel_value))
+ if ((0 == interval.rel_value_us) || (0 == delta.rel_value_us))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Speed up disabled\n");
return GNUNET_OK;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Speed up execution time %llu ms every %llu ms\n",
- delta.rel_value, interval.rel_value);
+ "Speed up execution by %s\n",
+ GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_NO));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Speed up executed every %s\n",
+ GNUNET_STRINGS_relative_time_to_string (interval, GNUNET_NO));
speedup_task = GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO, &do_speedup, NULL);
return GNUNET_OK;
}
@@ -92,7 +95,8 @@ GNUNET_SPEEDUP_stop_ ( )
GNUNET_SCHEDULER_cancel (speedup_task);
speedup_task = GNUNET_SCHEDULER_NO_TASK;
}
- if ((0 != interval.rel_value) && (0 != delta.rel_value))
+ if ( (0 != interval.rel_value_us) &&
+ (0 != delta.rel_value_us) )
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Stopped execution speed up\n");
}
diff --git a/src/util/strings.c b/src/util/strings.c
index 8bbc904bc..da02a9c4f 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2005, 2006 Christian Grothoff (and other contributing authors)
+ (C) 2005-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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -300,18 +300,19 @@ GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time,
{
static const struct ConversionTable table[] =
{
- { "ms", 1},
- { "s", 1000},
- { "\"", 1000},
- { "m", 60 * 1000},
- { "min", 60 * 1000},
- { "minutes", 60 * 1000},
- { "'", 60 * 1000},
- { "h", 60 * 60 * 1000},
- { "d", 24 * 60 * 60 * 1000},
- { "day", 24 * 60 * 60 * 1000},
- { "days", 24 * 60 * 60 * 1000},
- { "a", 31536000000LL /* year */ },
+ { "us", 1},
+ { "ms", 1000 },
+ { "s", 1000 * 1000LL },
+ { "\"", 1000 * 1000LL },
+ { "m", 60 * 1000 * 1000LL},
+ { "min", 60 * 1000 * 1000LL},
+ { "minutes", 60 * 1000 * 1000LL},
+ { "'", 60 * 1000 * 1000LL},
+ { "h", 60 * 60 * 1000 * 1000LL},
+ { "d", 24 * 60 * 60 * 1000LL * 1000LL},
+ { "day", 24 * 60 * 60 * 1000LL * 1000LL},
+ { "days", 24 * 60 * 60 * 1000LL * 1000LL},
+ { "a", 31536000000000LL /* year */ },
{ NULL, 0}
};
int ret;
@@ -325,7 +326,7 @@ GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time,
ret = convert_with_table (fancy_time,
table,
&val);
- rtime->rel_value = (uint64_t) val;
+ rtime->rel_value_us = (uint64_t) val;
return ret;
}
@@ -363,9 +364,9 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time,
(NULL == strptime (fancy_time, "%Y", &tv)) )
return GNUNET_SYSERR;
t = mktime (&tv);
- atime->abs_value = (uint64_t) ((uint64_t) t * 1000LL);
+ atime->abs_value_us = (uint64_t) ((uint64_t) t * 1000LL * 1000LL);
#if LINUX
- atime->abs_value -= 1000LL * timezone;
+ atime->abs_value_us -= 1000LL * 1000LL * timezone;
#endif
return GNUNET_OK;
}
@@ -380,7 +381,10 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time,
* string is returned.
*/
char *
-GNUNET_STRINGS_conv (const char *input, size_t len, const char *input_charset, const char *output_charset)
+GNUNET_STRINGS_conv (const char *input,
+ size_t len,
+ const char *input_charset,
+ const char *output_charset)
{
char *ret;
uint8_t *u8_string;
@@ -634,41 +638,48 @@ GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta,
int do_round)
{
static char buf[128];
- const char *unit = _( /* time unit */ "ms");
- uint64_t dval = delta.rel_value;
+ const char *unit = _( /* time unit */ "┬Ás");
+ uint64_t dval = delta.rel_value_us;
- if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value == delta.rel_value)
+ if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == delta.rel_value_us)
return _("forever");
- if (0 == delta.rel_value)
+ if (0 == delta.rel_value_us)
return _("0 ms");
if ( ( (GNUNET_YES == do_round) &&
(dval > 5 * 1000) ) ||
(0 == (dval % 1000) ))
{
dval = dval / 1000;
- unit = _( /* time unit */ "s");
- if ( ( (GNUNET_YES == do_round) &&
- (dval > 5 * 60) ) ||
- (0 == (dval % 60) ) )
+ unit = _( /* time unit */ "ms");
+ if ( ( (GNUNET_YES == do_round) &&
+ (dval > 5 * 1000) ) ||
+ (0 == (dval % 1000) ))
{
- dval = dval / 60;
- unit = _( /* time unit */ "m");
+ dval = dval / 1000;
+ unit = _( /* time unit */ "s");
if ( ( (GNUNET_YES == do_round) &&
- (dval > 5 * 60) ) ||
- (0 == (dval % 60) ))
+ (dval > 5 * 60) ) ||
+ (0 == (dval % 60) ) )
{
- dval = dval / 60;
- unit = _( /* time unit */ "h");
- if ( ( (GNUNET_YES == do_round) &&
- (dval > 5 * 24) ) ||
- (0 == (dval % 24)) )
+ dval = dval / 60;
+ unit = _( /* time unit */ "m");
+ if ( ( (GNUNET_YES == do_round) &&
+ (dval > 5 * 60) ) ||
+ (0 == (dval % 60) ))
{
- dval = dval / 24;
- if (1 == dval)
- unit = _( /* time unit */ "day");
- else
- unit = _( /* time unit */ "days");
- }
+ dval = dval / 60;
+ unit = _( /* time unit */ "h");
+ if ( ( (GNUNET_YES == do_round) &&
+ (dval > 5 * 24) ) ||
+ (0 == (dval % 24)) )
+ {
+ dval = dval / 24;
+ if (1 == dval)
+ unit = _( /* time unit */ "day");
+ else
+ unit = _( /* time unit */ "days");
+ }
+ }
}
}
}
@@ -693,9 +704,9 @@ GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t)
time_t tt;
struct tm *tp;
- if (t.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
+ if (t.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
return _("end of time");
- tt = t.abs_value / 1000;
+ tt = t.abs_value_us / 1000LL / 1000LL;
tp = gmtime (&tt);
strftime (buf, sizeof (buf), "%a %b %d %H:%M:%S %Y", tp);
return buf;
diff --git a/src/util/test_common_logging_dummy.c b/src/util/test_common_logging_dummy.c
index a1f479976..a360d5dee 100644
--- a/src/util/test_common_logging_dummy.c
+++ b/src/util/test_common_logging_dummy.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2008 Christian Grothoff (and other contributing authors)
+ (C) 2008-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
@@ -59,7 +59,7 @@ expensive_func ()
GNUNET_log (kind, "L%s %d\n", lvl, expensive_func());\
t2 = GNUNET_TIME_absolute_get ();\
printf ("1%s %llu\n", lvl,\
- (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2).rel_value); \
+ (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2).rel_value_us); \
}
#define pr2(kind,lvl) {\
@@ -68,7 +68,7 @@ expensive_func ()
GNUNET_log (kind, "L%s %d\n", lvl, expensive_func());\
t2 = GNUNET_TIME_absolute_get ();\
printf ("2%s %llu\n", lvl,\
- (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2).rel_value); \
+ (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2).rel_value_us); \
}
int
diff --git a/src/util/test_crypto_ecc.c b/src/util/test_crypto_ecc.c
index 00d264e0f..bb5fb002f 100644
--- a/src/util/test_crypto_ecc.c
+++ b/src/util/test_crypto_ecc.c
@@ -166,9 +166,9 @@ testSignPerformance ()
continue;
}
}
- printf ("%d ECC sign operations %llu ms\n", ITER,
- (unsigned long long)
- GNUNET_TIME_absolute_get_duration (start).rel_value);
+ printf ("%d ECC sign operations %s\n", ITER,
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
+ GNUNET_YES));
return ok;
}
#endif
diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c
index 132066979..ce96213c7 100644
--- a/src/util/test_scheduler_delay.c
+++ b/src/util/test_scheduler_delay.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2006 Christian Grothoff (and other contributing authors)
+ (C) 2001-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
@@ -20,13 +20,11 @@
/**
* @file util/test_scheduler_delay.c
* @brief testcase for delay of scheduler, measures how
- * precise the timers are. Expect values between 10 and 20 ms on
+ * precise the timers are. Expect values between 0.2 and 2 ms on
* modern machines.
*/
#include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_scheduler_lib.h"
-#include "gnunet_time_lib.h"
+#include "gnunet_util_lib.h"
static struct GNUNET_TIME_Absolute target;
@@ -36,7 +34,8 @@ static unsigned long long cumDelta;
#define INCR 47
-#define MAXV 1500
+#define MAXV 5000
+
/**
* Signature of the main function of a task.
@@ -45,18 +44,19 @@ static unsigned long long cumDelta;
* @param tc context
*/
static void
-test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+test_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_TIME_Absolute now;
now = GNUNET_TIME_absolute_get ();
- if (now.abs_value > target.abs_value)
- cumDelta += (now.abs_value - target.abs_value);
+ if (now.abs_value_us > target.abs_value_us)
+ cumDelta += (now.abs_value_us - target.abs_value_us);
else
- cumDelta += (target.abs_value - now.abs_value);
+ cumDelta += (target.abs_value_us - now.abs_value_us);
target =
GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_MILLISECONDS, i));
+ (GNUNET_TIME_UNIT_MICROSECONDS, i));
FPRINTF (stderr, "%s", ".");
if (i > MAXV)
{
@@ -64,7 +64,7 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
return;
}
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_MILLISECONDS, i), &test_task,
+ (GNUNET_TIME_UNIT_MICROSECONDS, i), &test_task,
NULL);
i += INCR;
}
@@ -76,13 +76,14 @@ main (int argc, char *argv[])
GNUNET_log_setup ("test-scheduler-delay", "WARNING", NULL);
target = GNUNET_TIME_absolute_get ();
GNUNET_SCHEDULER_run (&test_task, NULL);
- FPRINTF (stdout, "Sleep precision: %llu ms. ",
- cumDelta / 1000 / (MAXV / INCR));
- if (cumDelta <= 10 * MAXV / INCR)
+ FPRINTF (stdout,
+ "Sleep precision: %llu microseconds (average delta). ",
+ cumDelta / (MAXV / INCR));
+ if (cumDelta <= 500 * MAXV / INCR)
FPRINTF (stdout, "%s", "Timer precision is excellent.\n");
- else if (cumDelta <= 50 * MAXV / INCR) /* 50 ms average deviation */
+ else if (cumDelta <= 5000 * MAXV / INCR) /* 5 ms average deviation */
FPRINTF (stdout, "%s", "Timer precision is good.\n");
- else if (cumDelta > 250 * MAXV / INCR)
+ else if (cumDelta > 25000 * MAXV / INCR)
FPRINTF (stdout, "%s", "Timer precision is awful.\n");
else
FPRINTF (stdout, "%s", "Timer precision is acceptable.\n");
diff --git a/src/util/test_speedup.c b/src/util/test_speedup.c
index 03cffbd54..a2e6bb29c 100644
--- a/src/util/test_speedup.c
+++ b/src/util/test_speedup.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2006, 2009 Christian Grothoff (and other contributing authors)
+ (C) 2011-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
@@ -22,10 +22,7 @@
* @brief testcase for speedup.c
*/
#include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_program_lib.h"
-#include "gnunet_time_lib.h"
-#include "gnunet_strings_lib.h"
+#include "gnunet_util_lib.h"
/**
* Start time of the testcase
@@ -100,19 +97,23 @@ main (int argc, char *argv[])
"nohelp", options, &check, NULL);
end_real = time (NULL);
- delta = GNUNET_TIME_absolute_get_difference(start, end);
+ delta = GNUNET_TIME_absolute_get_difference (start, end);
- if (delta.rel_value > ((end_real - start_real) * 1500LL))
+ if (delta.rel_value_us > ((end_real - start_real) * 1500LL * 1000LL))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Execution time in GNUnet time: %llu ms\n",
- (unsigned long long) delta.rel_value);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Execution time in system time: %llu ms\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Execution time in GNUnet time: %s\n",
+ GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_YES));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Execution time in system time: %llu ms\n",
(unsigned long long) ((end_real - start_real) * 1000LL));
return 0;
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Execution time in GNUnet time: %llu ms\n",
- (unsigned long long) delta.rel_value);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Execution time in system time: %llu ms\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Execution time in GNUnet time: %s\n",
+ GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_YES));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Execution time in system time: %llu ms\n",
(unsigned long long) ((end_real - start_real) * 1000LL));
return 1;
}
diff --git a/src/util/test_strings.c b/src/util/test_strings.c
index e5247ad91..e0c3cfebf 100644
--- a/src/util/test_strings.c
+++ b/src/util/test_strings.c
@@ -87,7 +87,7 @@ main (int argc, char *argv[])
WANT ("btx", b);
if (0 != GNUNET_STRINGS_buffer_tokenize (buf, 2, 2, &r, &b))
return 1;
- at.abs_value = 5000;
+ at.abs_value_us = 5000000;
bc = GNUNET_STRINGS_absolute_time_to_string (at);
/* bc should be something like "Wed Dec 31 17:00:05 1969"
* where the details of the day and hour depend on the timezone;
@@ -105,7 +105,7 @@ main (int argc, char *argv[])
bc = GNUNET_STRINGS_absolute_time_to_string (at);
GNUNET_assert (GNUNET_OK ==
GNUNET_STRINGS_fancy_time_to_absolute (bc, &atx));
- GNUNET_assert (atx.abs_value == at.abs_value);
+ GNUNET_assert (atx.abs_value_us == at.abs_value_us);
GNUNET_log_skip (2, GNUNET_NO);
b = GNUNET_STRINGS_to_utf8 ("TEST", 4, "unknown");
@@ -116,7 +116,7 @@ main (int argc, char *argv[])
GNUNET_STRINGS_fancy_time_to_relative ("15m", &rt));
GNUNET_assert (GNUNET_OK ==
GNUNET_STRINGS_fancy_time_to_relative ("15 m", &rtx));
- GNUNET_assert (rt.rel_value == rtx.rel_value);
+ GNUNET_assert (rt.rel_value_us == rtx.rel_value_us);
return 0;
}
diff --git a/src/util/test_time.c b/src/util/test_time.c
index cd1175416..467336e0a 100644
--- a/src/util/test_time.c
+++ b/src/util/test_time.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2006, 2009 Christian Grothoff (and other contributing authors)
+ (C) 2001-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
@@ -22,8 +22,7 @@
* @brief testcase for time.c
*/
#include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_time_lib.h"
+#include "gnunet_util_lib.h"
int
@@ -46,186 +45,186 @@ main (int argc, char *argv[])
forever = GNUNET_TIME_UNIT_FOREVER_ABS;
relForever = GNUNET_TIME_UNIT_FOREVER_REL;
relUnit = GNUNET_TIME_UNIT_MILLISECONDS;
- zero.abs_value = 0;
+ zero.abs_value_us = 0;
last = now = GNUNET_TIME_absolute_get ();
- while (now.abs_value == last.abs_value)
+ while (now.abs_value_us == last.abs_value_us)
now = GNUNET_TIME_absolute_get ();
- GNUNET_assert (now.abs_value > last.abs_value);
+ GNUNET_assert (now.abs_value_us > last.abs_value_us);
/* test overflow checking in multiply */
- rel = GNUNET_TIME_UNIT_SECONDS;
+ rel = GNUNET_TIME_UNIT_MILLISECONDS;
GNUNET_log_skip (1, GNUNET_NO);
for (i = 0; i < 55; i++)
rel = GNUNET_TIME_relative_multiply (rel, 2);
GNUNET_log_skip (0, GNUNET_NO);
- GNUNET_assert (rel.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value);
+ GNUNET_assert (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us);
/*check zero */
- rel.rel_value = (UINT64_MAX) - 1024;
- GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value ==
- GNUNET_TIME_relative_multiply (rel, 0).rel_value);
+ rel.rel_value_us = (UINT64_MAX) - 1024;
+ GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value_us ==
+ GNUNET_TIME_relative_multiply (rel, 0).rel_value_us);
/* test infinity-check for relative to absolute */
GNUNET_log_skip (1, GNUNET_NO);
last = GNUNET_TIME_relative_to_absolute (rel);
- GNUNET_assert (last.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value);
+ GNUNET_assert (last.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us);
GNUNET_log_skip (0, GNUNET_YES);
/*check relative to absolute */
- rel.rel_value = 0;
- GNUNET_assert (GNUNET_TIME_absolute_get ().abs_value ==
- GNUNET_TIME_relative_to_absolute (rel).abs_value);
+ rel.rel_value_us = 0;
+ GNUNET_assert (GNUNET_TIME_absolute_get ().abs_value_us ==
+ GNUNET_TIME_relative_to_absolute (rel).abs_value_us);
/*check forever */
- rel.rel_value = UINT64_MAX;
- GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value ==
- GNUNET_TIME_relative_to_absolute (rel).abs_value);
+ rel.rel_value_us = UINT64_MAX;
+ GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us ==
+ GNUNET_TIME_relative_to_absolute (rel).abs_value_us);
/* check overflow for r2a */
- rel.rel_value = (UINT64_MAX) - 1024;
+ rel.rel_value_us = (UINT64_MAX) - 1024;
GNUNET_log_skip (1, GNUNET_NO);
last = GNUNET_TIME_relative_to_absolute (rel);
GNUNET_log_skip (0, GNUNET_NO);
- GNUNET_assert (last.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value);
+ GNUNET_assert (last.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us);
/* check overflow for relative add */
GNUNET_log_skip (1, GNUNET_NO);
rel = GNUNET_TIME_relative_add (rel, rel);
GNUNET_log_skip (0, GNUNET_NO);
- GNUNET_assert (rel.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value);
+ GNUNET_assert (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us);
GNUNET_log_skip (1, GNUNET_NO);
rel = GNUNET_TIME_relative_add (relForever, relForever);
GNUNET_log_skip (0, GNUNET_NO);
- GNUNET_assert (rel.rel_value == relForever.rel_value);
+ GNUNET_assert (rel.rel_value_us == relForever.rel_value_us);
GNUNET_log_skip (1, GNUNET_NO);
rel = GNUNET_TIME_relative_add (relUnit, relUnit);
- GNUNET_assert (rel.rel_value == 2 * relUnit.rel_value);
+ GNUNET_assert (rel.rel_value_us == 2 * relUnit.rel_value_us);
/* check relation check in get_duration */
- future.abs_value = now.abs_value + 1000000;
- GNUNET_assert (GNUNET_TIME_absolute_get_difference (now, future).rel_value ==
+ future.abs_value_us = now.abs_value_us + 1000000;
+ GNUNET_assert (GNUNET_TIME_absolute_get_difference (now, future).rel_value_us ==
1000000);
- GNUNET_assert (GNUNET_TIME_absolute_get_difference (future, now).rel_value ==
+ GNUNET_assert (GNUNET_TIME_absolute_get_difference (future, now).rel_value_us ==
0);
- GNUNET_assert (GNUNET_TIME_absolute_get_difference (zero, forever).rel_value
- == forever.abs_value);
+ GNUNET_assert (GNUNET_TIME_absolute_get_difference (zero, forever).rel_value_us
+ == forever.abs_value_us);
- past.abs_value = now.abs_value - 1000000;
+ past.abs_value_us = now.abs_value_us - 1000000;
rel = GNUNET_TIME_absolute_get_duration (future);
- GNUNET_assert (rel.rel_value == 0);
+ GNUNET_assert (rel.rel_value_us == 0);
rel = GNUNET_TIME_absolute_get_duration (past);
- GNUNET_assert (rel.rel_value >= 1000000);
+ GNUNET_assert (rel.rel_value_us >= 1000000);
/* check get remaining */
rel = GNUNET_TIME_absolute_get_remaining (now);
- GNUNET_assert (rel.rel_value == 0);
+ GNUNET_assert (rel.rel_value_us == 0);
rel = GNUNET_TIME_absolute_get_remaining (past);
- GNUNET_assert (rel.rel_value == 0);
+ GNUNET_assert (rel.rel_value_us == 0);
rel = GNUNET_TIME_absolute_get_remaining (future);
- GNUNET_assert (rel.rel_value > 0);
- GNUNET_assert (rel.rel_value <= 1000000);
+ GNUNET_assert (rel.rel_value_us > 0);
+ GNUNET_assert (rel.rel_value_us <= 1000000);
forever = GNUNET_TIME_UNIT_FOREVER_ABS;
- GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value ==
- GNUNET_TIME_absolute_get_remaining (forever).rel_value);
+ GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us ==
+ GNUNET_TIME_absolute_get_remaining (forever).rel_value_us);
/* check endianess */
reln = GNUNET_TIME_relative_hton (rel);
- GNUNET_assert (rel.rel_value == GNUNET_TIME_relative_ntoh (reln).rel_value);
+ GNUNET_assert (rel.rel_value_us == GNUNET_TIME_relative_ntoh (reln).rel_value_us);
nown = GNUNET_TIME_absolute_hton (now);
- GNUNET_assert (now.abs_value == GNUNET_TIME_absolute_ntoh (nown).abs_value);
+ GNUNET_assert (now.abs_value_us == GNUNET_TIME_absolute_ntoh (nown).abs_value_us);
/* check absolute addition */
future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_SECONDS);
- GNUNET_assert (future.abs_value == now.abs_value + 1000);
+ GNUNET_assert (future.abs_value_us == now.abs_value_us + 1000 * 1000LL);
future = GNUNET_TIME_absolute_add (forever, GNUNET_TIME_UNIT_ZERO);
- GNUNET_assert (future.abs_value == forever.abs_value);
+ GNUNET_assert (future.abs_value_us == forever.abs_value_us);
- rel.rel_value = (UINT64_MAX) - 1024;
- now.abs_value = rel.rel_value;
+ rel.rel_value_us = (UINT64_MAX) - 1024;
+ now.abs_value_us = rel.rel_value_us;
future = GNUNET_TIME_absolute_add (now, rel);
- GNUNET_assert (future.abs_value == forever.abs_value);
+ GNUNET_assert (future.abs_value_us == forever.abs_value_us);
/* check zero */
future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_ZERO);
- GNUNET_assert (future.abs_value == now.abs_value);
+ GNUNET_assert (future.abs_value_us == now.abs_value_us);
- GNUNET_assert (forever.abs_value ==
+ GNUNET_assert (forever.abs_value_us ==
GNUNET_TIME_absolute_subtract (forever,
- GNUNET_TIME_UNIT_MINUTES).abs_value);
+ GNUNET_TIME_UNIT_MINUTES).abs_value_us);
/*check absolute subtract */
- now.abs_value = 50000;
- rel.rel_value = 100000;
- GNUNET_assert (GNUNET_TIME_UNIT_ZERO_ABS.abs_value ==
- (GNUNET_TIME_absolute_subtract (now, rel)).abs_value);
- rel.rel_value = 10000;
- GNUNET_assert (40000 == (GNUNET_TIME_absolute_subtract (now, rel)).abs_value);
+ now.abs_value_us = 50000;
+ rel.rel_value_us = 100000;
+ GNUNET_assert (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us ==
+ (GNUNET_TIME_absolute_subtract (now, rel)).abs_value_us);
+ rel.rel_value_us = 10000;
+ GNUNET_assert (40000 == (GNUNET_TIME_absolute_subtract (now, rel)).abs_value_us);
/*check relative divide */
- GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value ==
- (GNUNET_TIME_relative_divide (rel, 0)).rel_value);
+ GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us ==
+ (GNUNET_TIME_relative_divide (rel, 0)).rel_value_us);
rel = GNUNET_TIME_UNIT_FOREVER_REL;
- GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value ==
- (GNUNET_TIME_relative_divide (rel, 2)).rel_value);
+ GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us ==
+ (GNUNET_TIME_relative_divide (rel, 2)).rel_value_us);
rel = GNUNET_TIME_relative_divide (relUnit, 2);
- GNUNET_assert (rel.rel_value == relUnit.rel_value / 2);
+ GNUNET_assert (rel.rel_value_us == relUnit.rel_value_us / 2);
/* check Return absolute time of 0ms */
zero = GNUNET_TIME_UNIT_ZERO_ABS;
/* check GNUNET_TIME_calculate_eta */
- last.abs_value = GNUNET_TIME_absolute_get ().abs_value - 1024;
+ last.abs_value_us = GNUNET_TIME_absolute_get ().abs_value_us - 1024;
forever = GNUNET_TIME_UNIT_FOREVER_ABS;
- forever.abs_value = forever.abs_value - 1024;
- GNUNET_assert (GNUNET_TIME_UNIT_ZERO_ABS.abs_value ==
- GNUNET_TIME_calculate_eta (forever, 50000, 100000).rel_value);
+ forever.abs_value_us = forever.abs_value_us - 1024;
+ GNUNET_assert (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us ==
+ GNUNET_TIME_calculate_eta (forever, 50000, 100000).rel_value_us);
/* check zero */
GNUNET_log_skip (1, GNUNET_NO);
- GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value ==
- (GNUNET_TIME_calculate_eta (last, 60000, 50000)).rel_value);
+ GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value_us ==
+ (GNUNET_TIME_calculate_eta (last, 60000, 50000)).rel_value_us);
GNUNET_log_skip (0, GNUNET_YES);
/*check forever */
- GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value ==
- (GNUNET_TIME_calculate_eta (last, 0, 50000)).rel_value);
+ GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us ==
+ (GNUNET_TIME_calculate_eta (last, 0, 50000)).rel_value_us);
/*check relative subtract */
now = GNUNET_TIME_absolute_get ();
- rel.rel_value = now.abs_value;
- relForever.rel_value = rel.rel_value + 1024;
+ rel.rel_value_us = now.abs_value_us;
+ relForever.rel_value_us = rel.rel_value_us + 1024;
GNUNET_assert (1024 ==
- GNUNET_TIME_relative_subtract (relForever, rel).rel_value);
+ GNUNET_TIME_relative_subtract (relForever, rel).rel_value_us);
/*check zero */
- GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value ==
- GNUNET_TIME_relative_subtract (rel, relForever).rel_value);
+ GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value_us ==
+ GNUNET_TIME_relative_subtract (rel, relForever).rel_value_us);
/*check forever */
- rel.rel_value = UINT64_MAX;
- GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value ==
- GNUNET_TIME_relative_subtract (rel, relForever).rel_value);
+ rel.rel_value_us = UINT64_MAX;
+ GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us ==
+ GNUNET_TIME_relative_subtract (rel, relForever).rel_value_us);
/*check GNUNET_TIME_relative_min */
now = GNUNET_TIME_absolute_get ();
- rel.rel_value = now.abs_value;
- relForever.rel_value = rel.rel_value - 1024;
- GNUNET_assert (relForever.rel_value ==
- GNUNET_TIME_relative_min (rel, relForever).rel_value);
+ rel.rel_value_us = now.abs_value_us;
+ relForever.rel_value_us = rel.rel_value_us - 1024;
+ GNUNET_assert (relForever.rel_value_us ==
+ GNUNET_TIME_relative_min (rel, relForever).rel_value_us);
/*check GNUNET_TIME_relative_max */
- GNUNET_assert (rel.rel_value ==
- GNUNET_TIME_relative_max (rel, relForever).rel_value);
+ GNUNET_assert (rel.rel_value_us ==
+ GNUNET_TIME_relative_max (rel, relForever).rel_value_us);
/*check GNUNET_TIME_absolute_min */
now = GNUNET_TIME_absolute_get ();
- last.abs_value = now.abs_value - 1024;
- GNUNET_assert (last.abs_value ==
- GNUNET_TIME_absolute_min (now, last).abs_value);
+ last.abs_value_us = now.abs_value_us - 1024;
+ GNUNET_assert (last.abs_value_us ==
+ GNUNET_TIME_absolute_min (now, last).abs_value_us);
/*check GNUNET_TIME_absolute_max */
- GNUNET_assert (now.abs_value ==
- GNUNET_TIME_absolute_max (now, last).abs_value);
+ GNUNET_assert (now.abs_value_us ==
+ GNUNET_TIME_absolute_max (now, last).abs_value_us);
return 0;
}
diff --git a/src/util/time.c b/src/util/time.c
index 825b7f8ca..5e9a01b09 100644
--- a/src/util/time.c
+++ b/src/util/time.c
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2006, 2009 Christian Grothoff (and other contributing authors)
+ (C) 2001-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
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -70,9 +70,9 @@ GNUNET_TIME_absolute_get ()
struct timeval tv;
GETTIMEOFDAY (&tv, NULL);
- ret.abs_value =
- (uint64_t) (((uint64_t) tv.tv_sec * 1000LL) +
- ((uint64_t) tv.tv_usec / 1000LL)) + timestamp_offset;
+ ret.abs_value_us =
+ (uint64_t) (((uint64_t) tv.tv_sec * 1000LL * 1000LL) +
+ ((uint64_t) tv.tv_usec)) + timestamp_offset;
return ret;
}
@@ -102,7 +102,7 @@ GNUNET_TIME_absolute_get_zero_ ()
/**
- * Return relative time of 1ms.
+ * Return relative time of 1us.
*/
struct GNUNET_TIME_Relative
GNUNET_TIME_relative_get_unit_ ()
@@ -113,12 +113,23 @@ GNUNET_TIME_relative_get_unit_ ()
/**
+ * Return relative time of 1ms.
+ */
+struct GNUNET_TIME_Relative
+GNUNET_TIME_relative_get_millisecond_ ()
+{
+ static struct GNUNET_TIME_Relative one = { 1000 };
+ return one;
+}
+
+
+/**
* Return relative time of 1s.
*/
struct GNUNET_TIME_Relative
GNUNET_TIME_relative_get_second_ ()
{
- static struct GNUNET_TIME_Relative one = { 1000 };
+ static struct GNUNET_TIME_Relative one = { 1000 * 1000LL };
return one;
}
@@ -129,7 +140,7 @@ GNUNET_TIME_relative_get_second_ ()
struct GNUNET_TIME_Relative
GNUNET_TIME_relative_get_minute_ ()
{
- static struct GNUNET_TIME_Relative one = { 60 * 1000 };
+ static struct GNUNET_TIME_Relative one = { 60 * 1000 * 1000LL };
return one;
}
@@ -140,7 +151,7 @@ GNUNET_TIME_relative_get_minute_ ()
struct GNUNET_TIME_Relative
GNUNET_TIME_relative_get_hour_ ()
{
- static struct GNUNET_TIME_Relative one = { 60 * 60 * 1000 };
+ static struct GNUNET_TIME_Relative one = { 60 * 60 * 1000 * 1000LL };
return one;
}
@@ -176,16 +187,16 @@ GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel)
{
struct GNUNET_TIME_Absolute ret;
- if (rel.rel_value == UINT64_MAX)
+ if (rel.rel_value_us == UINT64_MAX)
return GNUNET_TIME_UNIT_FOREVER_ABS;
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
- if (rel.rel_value + now.abs_value < rel.rel_value)
+ if (rel.rel_value_us + now.abs_value_us < rel.rel_value_us)
{
GNUNET_break (0); /* overflow... */
return GNUNET_TIME_UNIT_FOREVER_ABS;
}
- ret.abs_value = rel.rel_value + now.abs_value;
+ ret.abs_value_us = rel.rel_value_us + now.abs_value_us;
return ret;
}
@@ -201,7 +212,7 @@ struct GNUNET_TIME_Relative
GNUNET_TIME_relative_min (struct GNUNET_TIME_Relative t1,
struct GNUNET_TIME_Relative t2)
{
- return (t1.rel_value < t2.rel_value) ? t1 : t2;
+ return (t1.rel_value_us < t2.rel_value_us) ? t1 : t2;
}
@@ -216,7 +227,7 @@ struct GNUNET_TIME_Relative
GNUNET_TIME_relative_max (struct GNUNET_TIME_Relative t1,
struct GNUNET_TIME_Relative t2)
{
- return (t1.rel_value > t2.rel_value) ? t1 : t2;
+ return (t1.rel_value_us > t2.rel_value_us) ? t1 : t2;
}
@@ -232,7 +243,7 @@ struct GNUNET_TIME_Absolute
GNUNET_TIME_absolute_min (struct GNUNET_TIME_Absolute t1,
struct GNUNET_TIME_Absolute t2)
{
- return (t1.abs_value < t2.abs_value) ? t1 : t2;
+ return (t1.abs_value_us < t2.abs_value_us) ? t1 : t2;
}
@@ -247,7 +258,7 @@ struct GNUNET_TIME_Absolute
GNUNET_TIME_absolute_max (struct GNUNET_TIME_Absolute t1,
struct GNUNET_TIME_Absolute t2)
{
- return (t1.abs_value > t2.abs_value) ? t1 : t2;
+ return (t1.abs_value_us > t2.abs_value_us) ? t1 : t2;
}
@@ -262,13 +273,13 @@ GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future)
{
struct GNUNET_TIME_Relative ret;
- if (future.abs_value == UINT64_MAX)
+ if (future.abs_value_us == UINT64_MAX)
return GNUNET_TIME_UNIT_FOREVER_REL;
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
- if (now.abs_value > future.abs_value)
+ if (now.abs_value_us > future.abs_value_us)
return GNUNET_TIME_UNIT_ZERO;
- ret.rel_value = future.abs_value - now.abs_value;
+ ret.rel_value_us = future.abs_value_us - now.abs_value_us;
return ret;
}
@@ -285,11 +296,11 @@ GNUNET_TIME_absolute_get_difference (struct GNUNET_TIME_Absolute start,
{
struct GNUNET_TIME_Relative ret;
- if (end.abs_value == UINT64_MAX)
+ if (end.abs_value_us == UINT64_MAX)
return GNUNET_TIME_UNIT_FOREVER_REL;
- if (end.abs_value < start.abs_value)
+ if (end.abs_value_us < start.abs_value_us)
return GNUNET_TIME_UNIT_ZERO;
- ret.rel_value = end.abs_value - start.abs_value;
+ ret.rel_value_us = end.abs_value_us - start.abs_value_us;
return ret;
}
@@ -306,10 +317,10 @@ GNUNET_TIME_absolute_get_duration (struct GNUNET_TIME_Absolute whence)
struct GNUNET_TIME_Relative ret;
now = GNUNET_TIME_absolute_get ();
- GNUNET_assert (whence.abs_value != UINT64_MAX);
- if (whence.abs_value > now.abs_value)
+ GNUNET_assert (whence.abs_value_us != UINT64_MAX);
+ if (whence.abs_value_us > now.abs_value_us)
return GNUNET_TIME_UNIT_ZERO;
- ret.rel_value = now.abs_value - whence.abs_value;
+ ret.rel_value_us = now.abs_value_us - whence.abs_value_us;
return ret;
}
@@ -326,14 +337,14 @@ GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start,
{
struct GNUNET_TIME_Absolute ret;
- if ((start.abs_value == UINT64_MAX) || (duration.rel_value == UINT64_MAX))
+ if ((start.abs_value_us == UINT64_MAX) || (duration.rel_value_us == UINT64_MAX))
return GNUNET_TIME_UNIT_FOREVER_ABS;
- if (start.abs_value + duration.rel_value < start.abs_value)
+ if (start.abs_value_us + duration.rel_value_us < start.abs_value_us)
{
GNUNET_break (0);
return GNUNET_TIME_UNIT_FOREVER_ABS;
}
- ret.abs_value = start.abs_value + duration.rel_value;
+ ret.abs_value_us = start.abs_value_us + duration.rel_value_us;
return ret;
}
@@ -352,11 +363,11 @@ GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start,
{
struct GNUNET_TIME_Absolute ret;
- if (start.abs_value <= duration.rel_value)
+ if (start.abs_value_us <= duration.rel_value_us)
return GNUNET_TIME_UNIT_ZERO_ABS;
- if (start.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
+ if (start.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
return GNUNET_TIME_UNIT_FOREVER_ABS;
- ret.abs_value = start.abs_value - duration.rel_value;
+ ret.abs_value_us = start.abs_value_us - duration.rel_value_us;
return ret;
}
@@ -372,10 +383,10 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel,
{
struct GNUNET_TIME_Relative ret;
- if (factor == 0)
+ if (0 == factor)
return GNUNET_TIME_UNIT_ZERO;
- ret.rel_value = rel.rel_value * (unsigned long long) factor;
- if (ret.rel_value / factor != rel.rel_value)
+ ret.rel_value_us = rel.rel_value_us * (unsigned long long) factor;
+ if (ret.rel_value_us / factor != rel.rel_value_us)
{
GNUNET_break (0);
return GNUNET_TIME_UNIT_FOREVER_REL;
@@ -397,10 +408,10 @@ GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel,
{
struct GNUNET_TIME_Relative ret;
- if ((factor == 0) ||
- (rel.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value))
+ if ((0 == factor) ||
+ (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us))
return GNUNET_TIME_UNIT_FOREVER_REL;
- ret.rel_value = rel.rel_value / (unsigned long long) factor;
+ ret.rel_value_us = rel.rel_value_us / (unsigned long long) factor;
return ret;
}
@@ -426,11 +437,11 @@ GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, uint64_t finished,
GNUNET_break (finished <= total);
if (finished >= total)
return GNUNET_TIME_UNIT_ZERO;
- if (finished == 0)
+ if (0 == finished)
return GNUNET_TIME_UNIT_FOREVER_REL;
dur = GNUNET_TIME_absolute_get_duration (start);
- exp = ((double) dur.rel_value) * ((double) total) / ((double) finished);
- ret.rel_value = ((uint64_t) exp) - dur.rel_value;
+ exp = ((double) dur.rel_value_us) * ((double) total) / ((double) finished);
+ ret.rel_value_us = ((uint64_t) exp) - dur.rel_value_us;
return ret;
}
@@ -448,14 +459,14 @@ GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1,
{
struct GNUNET_TIME_Relative ret;
- if ((a1.rel_value == UINT64_MAX) || (a2.rel_value == UINT64_MAX))
+ if ((a1.rel_value_us == UINT64_MAX) || (a2.rel_value_us == UINT64_MAX))
return GNUNET_TIME_UNIT_FOREVER_REL;
- if (a1.rel_value + a2.rel_value < a1.rel_value)
+ if (a1.rel_value_us + a2.rel_value_us < a1.rel_value_us)
{
GNUNET_break (0);
return GNUNET_TIME_UNIT_FOREVER_REL;
}
- ret.rel_value = a1.rel_value + a2.rel_value;
+ ret.rel_value_us = a1.rel_value_us + a2.rel_value_us;
return ret;
}
@@ -473,11 +484,11 @@ GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1,
{
struct GNUNET_TIME_Relative ret;
- if (a2.rel_value >= a1.rel_value)
+ if (a2.rel_value_us >= a1.rel_value_us)
return GNUNET_TIME_UNIT_ZERO;
- if (a1.rel_value == UINT64_MAX)
+ if (a1.rel_value_us == UINT64_MAX)
return GNUNET_TIME_UNIT_FOREVER_REL;
- ret.rel_value = a1.rel_value - a2.rel_value;
+ ret.rel_value_us = a1.rel_value_us - a2.rel_value_us;
return ret;
}
@@ -493,7 +504,7 @@ GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a)
{
struct GNUNET_TIME_RelativeNBO ret;
- ret.rel_value__ = GNUNET_htonll (a.rel_value);
+ ret.rel_value_us__ = GNUNET_htonll (a.rel_value_us);
return ret;
}
@@ -509,7 +520,7 @@ GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a)
{
struct GNUNET_TIME_Relative ret;
- ret.rel_value = GNUNET_ntohll (a.rel_value__);
+ ret.rel_value_us = GNUNET_ntohll (a.rel_value_us__);
return ret;
}
@@ -526,7 +537,7 @@ GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a)
{
struct GNUNET_TIME_AbsoluteNBO ret;
- ret.abs_value__ = GNUNET_htonll (a.abs_value);
+ ret.abs_value_us__ = GNUNET_htonll (a.abs_value_us);
return ret;
}
@@ -542,7 +553,7 @@ GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a)
{
struct GNUNET_TIME_Absolute ret;
- ret.abs_value = GNUNET_ntohll (a.abs_value__);
+ ret.abs_value_us = GNUNET_ntohll (a.abs_value_us__);
return ret;
}
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index b4a4bbff5..e2cf3e5c9 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -1120,7 +1120,7 @@ route_packet (struct DestinationEntry *destination,
ts->destination_port = destination_port;
ts->heap_node = GNUNET_CONTAINER_heap_insert (tunnel_heap,
ts,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_put (tunnel_map,
&key,
@@ -1137,7 +1137,7 @@ route_packet (struct DestinationEntry *destination,
is_new = GNUNET_NO;
GNUNET_CONTAINER_heap_update_cost (tunnel_heap,
ts->heap_node,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
}
GNUNET_assert (NULL != ts->tunnel);
@@ -2070,7 +2070,7 @@ receive_icmp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
}
GNUNET_CONTAINER_heap_update_cost (tunnel_heap,
ts->heap_node,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
return GNUNET_OK;
}
@@ -2225,7 +2225,7 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
}
GNUNET_CONTAINER_heap_update_cost (tunnel_heap,
ts->heap_node,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
return GNUNET_OK;
}
@@ -2367,7 +2367,7 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
}
GNUNET_CONTAINER_heap_update_cost (tunnel_heap,
ts->heap_node,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
return GNUNET_OK;
}
@@ -2708,7 +2708,7 @@ service_redirect_to_ip (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *cl
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
de->heap_node = GNUNET_CONTAINER_heap_insert (destination_heap,
de,
- GNUNET_TIME_absolute_ntoh (msg->expiration_time).abs_value);
+ GNUNET_TIME_absolute_ntoh (msg->expiration_time).abs_value_us);
GNUNET_STATISTICS_update (stats,
gettext_noop ("# Active destinations"),
1, GNUNET_NO);
@@ -2814,7 +2814,7 @@ service_redirect_to_service (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Clien
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
de->heap_node = GNUNET_CONTAINER_heap_insert (destination_heap,
de,
- GNUNET_TIME_absolute_ntoh (msg->expiration_time).abs_value);
+ GNUNET_TIME_absolute_ntoh (msg->expiration_time).abs_value_us);
while (GNUNET_CONTAINER_multihashmap_size (destination_map) > max_destination_mappings)
expire_destination (de);
ts = create_tunnel_to_destination (de,