Refactoring gnunet time
authorMatthias Wachs <wachs@net.in.tum.de>
Wed, 27 Oct 2010 09:39:41 +0000 (09:39 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Wed, 27 Oct 2010 09:39:41 +0000 (09:39 +0000)
src/datastore/datastore_api.c
src/datastore/gnunet-service-datastore.c
src/datastore/perf_datastore_api.c
src/datastore/perf_plugin_datastore.c
src/datastore/plugin_datastore_mysql.c
src/datastore/plugin_datastore_postgres.c
src/datastore/plugin_datastore_sqlite.c
src/datastore/test_datastore_api.c
src/datastore/test_datastore_api_management.c

index 3c34ee8e9d070fbb16f03e268995b5b426b2d6ea..4172b5c9983583b7d258ff54d95e769deffab144 100644 (file)
@@ -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;
index 6455ecb5b89128fcedba32d8a157b0e4cad078c7..6c064743e89d1019cc2c542106578e94cc5d4b55 100644 (file)
@@ -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;
index 3cb730bcba90a53d3151ae77166f436bd70a2c24..bb4f88cf3d3395e384ac3d300a5a979319435132 100644 (file)
@@ -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,
index 4d39d85ac4f29c0f0a520c59cc560683c62a7ed3..d870c0da32d692774f9266fd27304291cf59e16f 100644 (file)
@@ -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;
index 150dc665c2c8e41064b3c21f7500f3d2a984f5ef..0aefbb75d225d341888163651d0207cd36cbda1a 100644 (file)
@@ -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
index 3ec38c371329a62c0671399bae482e02467e91e5..248fe7a961b895721332ba14944d333439a73a02 100644 (file)
@@ -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++;
 
index 0a18b9b2f2ef0b7015c7611994b7b16f3ad9d873..05ebed7c5c79a397cd54cd0e55d0f619786be1e0 100644 (file)
@@ -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, 
index 10a195cfb10eae5ef5efbeb7c3d70c7bce3a673c..ae7782d6cfe2318ba97611272040c379f50669ed 100644 (file)
@@ -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);
 }
 
index 8e49409b6e2d8dff65fd7604fd7859fbd45c833d..72760de7af8321ffb5ce3527f083accecc9f7a56 100644 (file)
@@ -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);
 }