From 6cccd878eeab34115d87b75fa018582422f04dd4 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Wed, 27 Oct 2010 09:39:41 +0000 Subject: Refactoring gnunet time --- src/datastore/datastore_api.c | 16 +++++++------- src/datastore/gnunet-service-datastore.c | 6 ++--- src/datastore/perf_datastore_api.c | 2 +- src/datastore/perf_plugin_datastore.c | 8 +++---- src/datastore/plugin_datastore_mysql.c | 10 ++++----- src/datastore/plugin_datastore_postgres.c | 4 ++-- src/datastore/plugin_datastore_sqlite.c | 32 +++++++++++++-------------- src/datastore/test_datastore_api.c | 4 ++-- src/datastore/test_datastore_api_management.c | 4 ++-- 9 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 3c34ee8e9..4172b5c99 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c @@ -500,11 +500,11 @@ try_reconnect (void *cls, { struct GNUNET_DATASTORE_Handle *h = cls; - if (h->retry_time.value < GNUNET_CONSTANTS_SERVICE_RETRY.value) + if (h->retry_time.rel_value < GNUNET_CONSTANTS_SERVICE_RETRY.rel_value) h->retry_time = GNUNET_CONSTANTS_SERVICE_RETRY; else h->retry_time = GNUNET_TIME_relative_multiply (h->retry_time, 2); - if (h->retry_time.value > GNUNET_CONSTANTS_SERVICE_TIMEOUT.value) + if (h->retry_time.rel_value > GNUNET_CONSTANTS_SERVICE_TIMEOUT.rel_value) h->retry_time = GNUNET_CONSTANTS_SERVICE_TIMEOUT; h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg); @@ -784,7 +784,7 @@ process_status_message (void *cls, gettext_noop ("# status messages received"), 1, GNUNET_NO); - h->retry_time.value = 0; + h->retry_time.rel_value = 0; process_queue (h); if (rc.cont != NULL) rc.cont (rc.cont_cls, @@ -1055,7 +1055,7 @@ GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, "Asked to update entry %llu raising priority by %u and expiration to %llu\n", uid, (unsigned int) priority, - (unsigned long long) expiration.value); + (unsigned long long) expiration.abs_value); #endif qc.sc.cont = cont; qc.sc.cont_cls = cont_cls; @@ -1221,7 +1221,7 @@ process_result_message (void *cls, rc.iter (rc.iter_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); - h->retry_time.value = 0; + h->retry_time.rel_value = 0; h->result_count = 0; process_queue (h); return; @@ -1274,7 +1274,7 @@ process_result_message (void *cls, ntohl(dm->size), GNUNET_h2s(&dm->key)); #endif - h->retry_time.value = 0; + h->retry_time.rel_value = 0; rc.iter (rc.iter_cls, &dm->key, ntohl(dm->size), @@ -1318,7 +1318,7 @@ GNUNET_DATASTORE_get_random (struct GNUNET_DATASTORE_Handle *h, #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to get random entry in %llu ms\n", - (unsigned long long) timeout.value); + (unsigned long long) timeout.abs_value); #endif qc.rc.iter = iter; qc.rc.iter_cls = iter_cls; @@ -1378,7 +1378,7 @@ GNUNET_DATASTORE_get_zero_anonymity (struct GNUNET_DATASTORE_Handle *h, #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to get zero-anonymity entry in %llu ms\n", - (unsigned long long) timeout.value); + (unsigned long long) timeout.abs_value); #endif qc.rc.iter = iter; qc.rc.iter_cls = iter_cls; diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 6455ecb5b..6c064743e 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c @@ -350,7 +350,7 @@ expired_processor (void *cls, return GNUNET_SYSERR; } now = GNUNET_TIME_absolute_get (); - if (expiration.value > now.value) + if (expiration.abs_value > now.abs_value) { /* finished processing */ plugin->api->next_request (next_cls, GNUNET_YES); @@ -362,7 +362,7 @@ expired_processor (void *cls, "Deleting content `%s' of type %u that expired %llu ms ago\n", GNUNET_h2s (key), type, - (unsigned long long) (now.value - expiration.value)); + (unsigned long long) (now.abs_value - expiration.abs_value)); #endif GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes expired"), @@ -1486,7 +1486,7 @@ process_stat_in (void *cls, #if DEBUG_SQLITE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Notification from statistics about existing payload (%llu), new payload is %llu\n", - value, + abs_value, payload); #endif return GNUNET_OK; diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index 3cb730bcb..bb4f88cf3 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c @@ -295,7 +295,7 @@ run_continuation (void *cls, "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).value)); + 1000 * stored_ops / (1 + GNUNET_TIME_absolute_get_duration(start_time).rel_value)); crc->phase = RP_PUT; crc->j = 0; GNUNET_SCHEDULER_add_continuation (crc->sched, diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index 4d39d85ac..d870c0da3 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c @@ -114,7 +114,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 ().value; + key.bits[0] = (unsigned int) GNUNET_TIME_absolute_get ().abs_value; GNUNET_CRYPTO_hash (&key, sizeof (GNUNET_HashCode), &key); memset (value, i, size); if (i > 255) @@ -170,7 +170,7 @@ iterateDummy (void *cls, crc->end = GNUNET_TIME_absolute_get(); printf (crc->msg, crc->i, - (unsigned long long) (crc->end.value - crc->start.value), + (unsigned long long) (crc->end.abs_value - crc->start.abs_value), crc->cnt); if (crc->phase != RP_AN_GET) { @@ -191,7 +191,7 @@ iterateDummy (void *cls, #if VERBOSE fprintf (stderr, "Found result type=%u, priority=%u, size=%u, expire=%llu\n", type, priority, size, - (unsigned long long) expiration.value); + (unsigned long long) expiration.abs_value); #endif crc->cnt++; crc->api->next_request (next_cls, @@ -263,7 +263,7 @@ test (void *cls, crc->end = GNUNET_TIME_absolute_get (); printf ("%3u insertion took %20llums for %u\n", crc->i, - (unsigned long long) (crc->end.value - crc->start.value), + (unsigned long long) (crc->end.abs_value - crc->start.abs_value), (unsigned int) PUT_10); crc->i++; crc->phase = RP_LP_GET; diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c index 150dc665c..0aefbb75d 100644 --- a/src/datastore/plugin_datastore_mysql.c +++ b/src/datastore/plugin_datastore_mysql.c @@ -1062,7 +1062,7 @@ iterator_helper_prepare (void *cls, &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONGLONG, - &nrc->now.value, + &nrc->now.abs_value, GNUNET_YES, MYSQL_TYPE_LONGLONG, &nrc->last_expire, @@ -1071,7 +1071,7 @@ iterator_helper_prepare (void *cls, &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONGLONG, - &nrc->now.value, + &nrc->now.abs_value, GNUNET_YES, -1); break; default: @@ -1199,7 +1199,7 @@ mysql_next_request_cont (void *next_cls, exp); #endif GNUNET_assert (nrc->plugin->next_task == GNUNET_SCHEDULER_NO_TASK); - expiration.value = exp; + expiration.abs_value = exp; ret = nrc->dviter (nrc->dviter_cls, nrc, &key, @@ -1368,7 +1368,7 @@ mysql_plugin_put (void *cls, unsigned int itype = type; unsigned int ipriority = priority; unsigned int ianonymity = anonymity; - unsigned long long lexpiration = expiration.value; + unsigned long long lexpiration = expiration.abs_value; unsigned long hashSize; unsigned long hashSize2; unsigned long long vkey; @@ -1720,7 +1720,7 @@ mysql_plugin_update (void *cls, { struct Plugin *plugin = cls; unsigned long long vkey = uid; - unsigned long long lexpire = expire.value; + unsigned long long lexpire = expire.abs_value; int ret; #if DEBUG_MYSQL diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index 3ec38c371..248fe7a96 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c @@ -767,12 +767,12 @@ postgres_next_request_cont (void *next_cls, 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.value = GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, 0, 3)); + expiration_time.abs_value = GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, 0, 3)); memcpy (&key, PQgetvalue (res, 0, 4), sizeof (GNUNET_HashCode)); size = PQgetlength (res, 0, 5); nrc->blast_prio = htonl (priority); - nrc->blast_expire = GNUNET_htonll (expiration_time.value); + nrc->blast_expire = GNUNET_htonll (expiration_time.abs_value); nrc->blast_rowid = htonl (rowid); nrc->count++; diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index 0a18b9b2f..05ebed7c5 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c @@ -556,7 +556,7 @@ sqlite_next_request_cont (void *cls, priority = sqlite3_column_int (nc->stmt, 2); anonymity = sqlite3_column_int (nc->stmt, 3); - expiration.value = sqlite3_column_int64 (nc->stmt, 4); + expiration.abs_value = sqlite3_column_int64 (nc->stmt, 4); key = sqlite3_column_blob (nc->stmt, 5); nc->lastPriority = priority; nc->lastExpiration = expiration; @@ -667,8 +667,8 @@ sqlite_plugin_put (void *cls, type, GNUNET_h2s(key), priority, - (unsigned long long) GNUNET_TIME_absolute_get_remaining (expiration).value, - (long long) expiration.value); + (unsigned long long) GNUNET_TIME_absolute_get_remaining (expiration).abs_value, + (long long) expiration.abs_value); #endif GNUNET_CRYPTO_hash (data, size, &vhash); stmt = plugin->insertContent; @@ -676,7 +676,7 @@ sqlite_plugin_put (void *cls, (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.value)) || + (SQLITE_OK != sqlite3_bind_int64 (stmt, 5, expiration.abs_value)) || (SQLITE_OK != sqlite3_bind_blob (stmt, 6, key, sizeof (GNUNET_HashCode), SQLITE_TRANSIENT)) || @@ -763,7 +763,7 @@ sqlite_plugin_update (void *cls, int n; sqlite3_bind_int (plugin->updPrio, 1, delta); - sqlite3_bind_int64 (plugin->updPrio, 2, expire.value); + sqlite3_bind_int64 (plugin->updPrio, 2, expire.abs_value); sqlite3_bind_int64 (plugin->updPrio, 3, uid); n = sqlite3_step (plugin->updPrio); if (n != SQLITE_DONE) @@ -871,10 +871,10 @@ iter_next_prepare (void *cls, #if DEBUG_SQLITE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Restricting to results larger than the last expiration %llu\n", - (unsigned long long) nc->lastExpiration.value); + (unsigned long long) nc->lastExpiration.abs_value); #endif - sqlite3_bind_int64 (ic->stmt_1, 1, nc->lastExpiration.value); - sqlite3_bind_int64 (ic->stmt_2, 1, nc->lastExpiration.value); + sqlite3_bind_int64 (ic->stmt_1, 1, nc->lastExpiration.abs_value); + sqlite3_bind_int64 (ic->stmt_2, 1, nc->lastExpiration.abs_value); } #if DEBUG_SQLITE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -974,7 +974,7 @@ basic_iter (struct Plugin *plugin, #if DEBUG_SQLITE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "At %llu, using queries `%s' and `%s'\n", - (unsigned long long) GNUNET_TIME_absolute_get ().value, + (unsigned long long) GNUNET_TIME_absolute_get ().abs_value, stmt_str_1, stmt_str_2); #endif @@ -1014,13 +1014,13 @@ basic_iter (struct Plugin *plugin, if (is_asc) { nc->lastPriority = 0; - nc->lastExpiration.value = 0; + nc->lastExpiration.abs_value = 0; memset (&nc->lastKey, 0, sizeof (GNUNET_HashCode)); } else { nc->lastPriority = 0x7FFFFFFF; - nc->lastExpiration.value = 0x7FFFFFFFFFFFFFFFLL; + nc->lastExpiration.abs_value = 0x7FFFFFFFFFFFFFFFLL; memset (&nc->lastKey, 255, sizeof (GNUNET_HashCode)); } sqlite_next_request (nc, GNUNET_NO); @@ -1077,9 +1077,9 @@ sqlite_plugin_iter_zero_anonymity (void *cls, now = GNUNET_TIME_absolute_get (); GNUNET_asprintf (&q1, SELECT_IT_NON_ANONYMOUS_1, - (unsigned long long) now.value); + (unsigned long long) now.abs_value); GNUNET_asprintf (&q2, SELECT_IT_NON_ANONYMOUS_2, - (unsigned long long) now.value); + (unsigned long long) now.abs_value); basic_iter (cls, type, GNUNET_NO, GNUNET_YES, @@ -1116,9 +1116,9 @@ sqlite_plugin_iter_ascending_expiration (void *cls, now = GNUNET_TIME_absolute_get (); GNUNET_asprintf (&q1, SELECT_IT_EXPIRATION_TIME_1, - (unsigned long long) 0*now.value); + (unsigned long long) 0*now.abs_value); GNUNET_asprintf (&q2, SELECT_IT_EXPIRATION_TIME_2, - (unsigned long long) 0*now.value); + (unsigned long long) 0*now.abs_value); basic_iter (cls, type, GNUNET_YES, GNUNET_NO, @@ -1152,7 +1152,7 @@ sqlite_plugin_iter_migration_order (void *cls, now = GNUNET_TIME_absolute_get (); GNUNET_asprintf (&q, SELECT_IT_MIGRATION_ORDER_2, - (unsigned long long) now.value); + (unsigned long long) now.abs_value); basic_iter (cls, type, GNUNET_NO, GNUNET_NO, diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index 10a195cfb..ae7782d6c 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c @@ -95,7 +95,7 @@ get_expiration (int i) { struct GNUNET_TIME_Absolute av; - av.value = now.value + 20000000 - i * 1000; + av.abs_value = now.abs_value + 20000000 - i * 1000; return av; } @@ -213,7 +213,7 @@ check_value (void *cls, GNUNET_assert (type == get_type (i)); GNUNET_assert (priority == get_priority (i)); GNUNET_assert (anonymity == get_anonymity(i)); - GNUNET_assert (expiration.value == get_expiration(i).value); + GNUNET_assert (expiration.abs_value == get_expiration(i).abs_value); GNUNET_DATASTORE_get_next (datastore, GNUNET_YES); } diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index 8e49409b6..72760de7a 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c @@ -91,7 +91,7 @@ get_expiration (int i) { struct GNUNET_TIME_Absolute av; - av.value = now.value + i * 1000; + av.abs_value = now.abs_value + i * 1000; return av; } @@ -183,7 +183,7 @@ check_value (void *cls, GNUNET_assert (type == get_type (i)); GNUNET_assert (priority == get_priority (i)); GNUNET_assert (anonymity == get_anonymity(i)); - GNUNET_assert (expiration.value == get_expiration(i).value); + GNUNET_assert (expiration.abs_value == get_expiration(i).abs_value); GNUNET_DATASTORE_get_next (datastore, GNUNET_YES); } -- cgit v1.2.3