aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
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/datastore
parent4a0398474db197abed243a123fb971fbeeffab4b (diff)
downloadgnunet-3d7fefedc9ba60bd8e8448efe8b628446d958536.tar.gz
gnunet-3d7fefedc9ba60bd8e8448efe8b628446d958536.zip
changing time measurement from milliseconds to microseconds
Diffstat (limited to 'src/datastore')
-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
11 files changed, 95 insertions, 72 deletions
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,
850 union QueueContext qc; 850 union QueueContext qc;
851 851
852 LOG (GNUNET_ERROR_TYPE_DEBUG, 852 LOG (GNUNET_ERROR_TYPE_DEBUG,
853 "Asked to put %u bytes of data under key `%s' for %llu ms\n", size, 853 "Asked to put %u bytes of data under key `%s' for %s\n", size,
854 GNUNET_h2s (key), 854 GNUNET_h2s (key),
855 GNUNET_TIME_absolute_get_remaining (expiration).rel_value); 855 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration),
856 GNUNET_YES));
856 msize = sizeof (struct DataMessage) + size; 857 msize = sizeof (struct DataMessage) + size;
857 GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); 858 GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
858 qc.sc.cont = cont; 859 qc.sc.cont = cont;
@@ -1037,8 +1038,10 @@ GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, uint64_t uid,
1037 if (cont == NULL) 1038 if (cont == NULL)
1038 cont = &drop_status_cont; 1039 cont = &drop_status_cont;
1039 LOG (GNUNET_ERROR_TYPE_DEBUG, 1040 LOG (GNUNET_ERROR_TYPE_DEBUG,
1040 "Asked to update entry %llu raising priority by %u and expiration to %llu\n", 1041 "Asked to update entry %llu raising priority by %u and expiration to %s\n",
1041 uid, (unsigned int) priority, (unsigned long long) expiration.abs_value); 1042 uid,
1043 (unsigned int) priority,
1044 GNUNET_STRINGS_absolute_time_to_string (expiration));
1042 qc.sc.cont = cont; 1045 qc.sc.cont = cont;
1043 qc.sc.cont_cls = cont_cls; 1046 qc.sc.cont_cls = cont_cls;
1044 qe = make_queue_entry (h, sizeof (struct UpdateMessage), queue_priority, 1047 qe = make_queue_entry (h, sizeof (struct UpdateMessage), queue_priority,
@@ -1268,8 +1271,9 @@ GNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h,
1268 union QueueContext qc; 1271 union QueueContext qc;
1269 1272
1270 GNUNET_assert (NULL != proc); 1273 GNUNET_assert (NULL != proc);
1271 LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to get replication entry in %llu ms\n", 1274 LOG (GNUNET_ERROR_TYPE_DEBUG,
1272 (unsigned long long) timeout.rel_value); 1275 "Asked to get replication entry in %s\n",
1276 GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_YES));
1273 qc.rc.proc = proc; 1277 qc.rc.proc = proc;
1274 qc.rc.proc_cls = proc_cls; 1278 qc.rc.proc_cls = proc_cls;
1275 qe = make_queue_entry (h, sizeof (struct GNUNET_MessageHeader), 1279 qe = make_queue_entry (h, sizeof (struct GNUNET_MessageHeader),
@@ -1330,9 +1334,9 @@ GNUNET_DATASTORE_get_zero_anonymity (struct GNUNET_DATASTORE_Handle *h,
1330 GNUNET_assert (NULL != proc); 1334 GNUNET_assert (NULL != proc);
1331 GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY); 1335 GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY);
1332 LOG (GNUNET_ERROR_TYPE_DEBUG, 1336 LOG (GNUNET_ERROR_TYPE_DEBUG,
1333 "Asked to get %llu-th zero-anonymity entry of type %d in %llu ms\n", 1337 "Asked to get %llu-th zero-anonymity entry of type %d in %s\n",
1334 (unsigned long long) offset, type, 1338 (unsigned long long) offset, type,
1335 (unsigned long long) timeout.rel_value); 1339 GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_YES));
1336 qc.rc.proc = proc; 1340 qc.rc.proc = proc;
1337 qc.rc.proc_cls = proc_cls; 1341 qc.rc.proc_cls = proc_cls;
1338 qe = make_queue_entry (h, sizeof (struct GetZeroAnonymityMessage), 1342 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,
332 return GNUNET_SYSERR; 332 return GNUNET_SYSERR;
333 } 333 }
334 now = GNUNET_TIME_absolute_get (); 334 now = GNUNET_TIME_absolute_get ();
335 if (expiration.abs_value > now.abs_value) 335 if (expiration.abs_value_us > now.abs_value_us)
336 { 336 {
337 /* finished processing */ 337 /* finished processing */
338 expired_kill_task = 338 expired_kill_task =
@@ -342,9 +342,11 @@ expired_processor (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
342 return GNUNET_SYSERR; 342 return GNUNET_SYSERR;
343 } 343 }
344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
345 "Deleting content `%s' of type %u that expired %llu ms ago\n", 345 "Deleting content `%s' of type %u that expired %s ago\n",
346 GNUNET_h2s (key), type, 346 GNUNET_h2s (key), type,
347 (unsigned long long) (now.abs_value - expiration.abs_value)); 347 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (expiration,
348 now),
349 GNUNET_YES));
348 min_expiration = now; 350 min_expiration = now;
349 GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes expired"), size, 351 GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes expired"), size,
350 GNUNET_YES); 352 GNUNET_YES);
@@ -404,11 +406,12 @@ quota_processor (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
404 if (NULL == key) 406 if (NULL == key)
405 return GNUNET_SYSERR; 407 return GNUNET_SYSERR;
406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
407 "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", 409 "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",
408 (unsigned long long) (size + GNUNET_DATASTORE_ENTRY_OVERHEAD), 410 (unsigned long long) (size + GNUNET_DATASTORE_ENTRY_OVERHEAD),
409 (unsigned int) priority, 411 (unsigned int) priority,
410 GNUNET_h2s (key), type, 412 GNUNET_h2s (key), type,
411 (unsigned long long) GNUNET_TIME_absolute_get_remaining (expiration).rel_value, 413 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration),
414 GNUNET_YES),
412 *need); 415 *need);
413 if (size + GNUNET_DATASTORE_ENTRY_OVERHEAD > *need) 416 if (size + GNUNET_DATASTORE_ENTRY_OVERHEAD > *need)
414 *need = 0; 417 *need = 0;
@@ -619,10 +622,11 @@ transmit_item (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
619 dm->key = *key; 622 dm->key = *key;
620 memcpy (&dm[1], data, size); 623 memcpy (&dm[1], data, size);
621 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 624 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
622 "Transmitting `%s' message for `%s' of type %u with expiration %llu (now: %llu)\n", 625 "Transmitting `%s' message for `%s' of type %u with expiration %s (in: %s)\n",
623 "DATA", GNUNET_h2s (key), type, 626 "DATA", GNUNET_h2s (key), type,
624 (unsigned long long) expiration.abs_value, 627 GNUNET_STRINGS_absolute_time_to_string (expiration),
625 (unsigned long long) GNUNET_TIME_absolute_get ().abs_value); 628 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration),
629 GNUNET_YES));
626 GNUNET_STATISTICS_update (stats, gettext_noop ("# results found"), 1, 630 GNUNET_STATISTICS_update (stats, gettext_noop ("# results found"), 1,
627 GNUNET_NO); 631 GNUNET_NO);
628 transmit (client, &dm->header); 632 transmit (client, &dm->header);
@@ -896,8 +900,8 @@ check_present (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
896 "Result already present in datastore\n"); 900 "Result already present in datastore\n");
897 /* FIXME: change API to allow increasing 'replication' counter */ 901 /* FIXME: change API to allow increasing 'replication' counter */
898 if ((ntohl (dm->priority) > 0) || 902 if ((ntohl (dm->priority) > 0) ||
899 (GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value > 903 (GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value_us >
900 expiration.abs_value)) 904 expiration.abs_value_us))
901 plugin->api->update (plugin->api->cls, uid, 905 plugin->api->update (plugin->api->cls, uid,
902 (int32_t) ntohl (dm->priority), 906 (int32_t) ntohl (dm->priority),
903 GNUNET_TIME_absolute_ntoh (dm->expiration), NULL); 907 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)
245#endif 245#endif
246 "Stored %llu kB / %lluk ops / %llu ops/s\n", stored_bytes / 1024, /* used size in k */ 246 "Stored %llu kB / %lluk ops / %llu ops/s\n", stored_bytes / 1024, /* used size in k */
247 stored_ops / 1024, /* total operations (in k) */ 247 stored_ops / 1024, /* total operations (in k) */
248 1000 * stored_ops / (1 + 248 1000LL * 1000LL * stored_ops / (1 +
249 GNUNET_TIME_absolute_get_duration 249 GNUNET_TIME_absolute_get_duration
250 (start_time).rel_value)); 250 (start_time).rel_value_us));
251 crc->phase = RP_PUT; 251 crc->phase = RP_PUT;
252 crc->j = 0; 252 crc->j = 0;
253 GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, 253 GNUNET_SCHEDULER_add_continuation (&run_continuation, crc,
@@ -257,7 +257,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
257 GNUNET_snprintf (gstr, sizeof (gstr), "DATASTORE-%s", plugin_name); 257 GNUNET_snprintf (gstr, sizeof (gstr), "DATASTORE-%s", plugin_name);
258 if ((crc->i == ITERATIONS) && (stored_ops > 0)) 258 if ((crc->i == ITERATIONS) && (stored_ops > 0))
259 GAUGER (gstr, "PUT operation duration", 259 GAUGER (gstr, "PUT operation duration",
260 GNUNET_TIME_absolute_get_duration (start_time).rel_value / 260 GNUNET_TIME_absolute_get_duration (start_time).rel_value_us / 1000LL /
261 stored_ops, "ms/operation"); 261 stored_ops, "ms/operation");
262 GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES); 262 GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES);
263 GNUNET_free (crc); 263 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)
115 size = size - (size & 7); /* always multiple of 8 */ 115 size = size - (size & 7); /* always multiple of 8 */
116 116
117 /* generate random key */ 117 /* generate random key */
118 key.bits[0] = (unsigned int) GNUNET_TIME_absolute_get ().abs_value; 118 key.bits[0] = (unsigned int) GNUNET_TIME_absolute_get ().abs_value_us;
119 GNUNET_CRYPTO_hash (&key, sizeof (struct GNUNET_HashCode), &key); 119 GNUNET_CRYPTO_hash (&key, sizeof (struct GNUNET_HashCode), &key);
120 memset (value, i, size); 120 memset (value, i, size);
121 if (i > 255) 121 if (i > 255)
@@ -164,9 +164,10 @@ iterate_zeros (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
164 hits[i / 8] |= (1 << (i % 8)); 164 hits[i / 8] |= (1 << (i % 8));
165 165
166 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 166 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
167 "Found result %d type=%u, priority=%u, size=%u, expire=%llu\n", 167 "Found result %d type=%u, priority=%u, size=%u, expire=%s\n",
168 i, 168 i,
169 type, priority, size, (unsigned long long) expiration.abs_value); 169 type, priority, size,
170 GNUNET_STRINGS_absolute_time_to_string (expiration));
170 crc->cnt++; 171 crc->cnt++;
171 if (crc->cnt == PUT_10 / 4 - 1) 172 if (crc->cnt == PUT_10 / 4 - 1)
172 { 173 {
@@ -178,13 +179,15 @@ iterate_zeros (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
178 bc++; 179 bc++;
179 180
180 crc->end = GNUNET_TIME_absolute_get (); 181 crc->end = GNUNET_TIME_absolute_get ();
181 printf ("%s took %llu ms yielding %u/%u items\n", 182 printf ("%s took %s yielding %u/%u items\n",
182 "Select random zero-anonymity item", 183 "Select random zero-anonymity item",
183 (unsigned long long) (crc->end.abs_value - crc->start.abs_value), 184 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (crc->start,
185 crc->end),
186 GNUNET_YES),
184 bc, crc->cnt); 187 bc, crc->cnt);
185 if (crc->cnt > 0) 188 if (crc->cnt > 0)
186 GAUGER (category, "Select random zero-anonymity item", 189 GAUGER (category, "Select random zero-anonymity item",
187 (crc->end.abs_value - crc->start.abs_value) / crc->cnt, 190 (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / crc->cnt,
188 "ms/item"); 191 "ms/item");
189 memset (hits, 0, sizeof (hits)); 192 memset (hits, 0, sizeof (hits));
190 crc->phase++; 193 crc->phase++;
@@ -220,13 +223,15 @@ expiration_get (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
220 bc++; 223 bc++;
221 224
222 crc->end = GNUNET_TIME_absolute_get (); 225 crc->end = GNUNET_TIME_absolute_get ();
223 printf ("%s took %llu ms yielding %u/%u items\n", 226 printf ("%s took %s yielding %u/%u items\n",
224 "Selecting and deleting by expiration", 227 "Selecting and deleting by expiration",
225 (unsigned long long) (crc->end.abs_value - crc->start.abs_value), 228 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (crc->start,
229 crc->end),
230 GNUNET_YES),
226 bc, (unsigned int) PUT_10); 231 bc, (unsigned int) PUT_10);
227 if (crc->cnt > 0) 232 if (crc->cnt > 0)
228 GAUGER (category, "Selecting and deleting by expiration", 233 GAUGER (category, "Selecting and deleting by expiration",
229 (crc->end.abs_value - crc->start.abs_value) / crc->cnt, 234 (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / crc->cnt,
230 "ms/item"); 235 "ms/item");
231 memset (hits, 0, sizeof (hits)); 236 memset (hits, 0, sizeof (hits));
232 if (++crc->iter == ITERATIONS) 237 if (++crc->iter == ITERATIONS)
@@ -266,13 +271,15 @@ replication_get (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
266 bc++; 271 bc++;
267 272
268 crc->end = GNUNET_TIME_absolute_get (); 273 crc->end = GNUNET_TIME_absolute_get ();
269 printf ("%s took %llu ms yielding %u/%u items\n", 274 printf ("%s took %s yielding %u/%u items\n",
270 "Selecting random item for replication", 275 "Selecting random item for replication",
271 (unsigned long long) (crc->end.abs_value - crc->start.abs_value), 276 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (crc->start,
277 crc->end),
278 GNUNET_YES),
272 bc, (unsigned int) PUT_10); 279 bc, (unsigned int) PUT_10);
273 if (crc->cnt > 0) 280 if (crc->cnt > 0)
274 GAUGER (category, "Selecting random item for replication", 281 GAUGER (category, "Selecting random item for replication",
275 (crc->end.abs_value - crc->start.abs_value) / crc->cnt, 282 (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / crc->cnt,
276 "ms/item"); 283 "ms/item");
277 memset (hits, 0, sizeof (hits)); 284 memset (hits, 0, sizeof (hits));
278 crc->phase++; 285 crc->phase++;
@@ -359,12 +366,14 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
359 putValue (crc->api, j, crc->i); 366 putValue (crc->api, j, crc->i);
360 crc->end = GNUNET_TIME_absolute_get (); 367 crc->end = GNUNET_TIME_absolute_get ();
361 { 368 {
362 printf ("%s took %llu ms for %llu items\n", "Storing an item", 369 printf ("%s took %s for %llu items\n", "Storing an item",
363 (unsigned long long) (crc->end.abs_value - crc->start.abs_value), 370 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (crc->start,
371 crc->end),
372 GNUNET_YES),
364 PUT_10); 373 PUT_10);
365 if (PUT_10 > 0) 374 if (PUT_10 > 0)
366 GAUGER (category, "Storing an item", 375 GAUGER (category, "Storing an item",
367 (crc->end.abs_value - crc->start.abs_value) / PUT_10, 376 (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / PUT_10,
368 "ms/item"); 377 "ms/item");
369 } 378 }
370 crc->i++; 379 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,
226 value->data = &value[1]; 226 value->data = &value[1];
227 value->expire_heap = GNUNET_CONTAINER_heap_insert (plugin->by_expiration, 227 value->expire_heap = GNUNET_CONTAINER_heap_insert (plugin->by_expiration,
228 value, 228 value,
229 expiration.abs_value); 229 expiration.abs_value_us);
230 value->replication_heap = GNUNET_CONTAINER_heap_insert (plugin->by_replication, 230 value->replication_heap = GNUNET_CONTAINER_heap_insert (plugin->by_replication,
231 value, 231 value,
232 replication); 232 replication);
@@ -628,12 +628,12 @@ heap_plugin_update (void *cls,
628 628
629 value = (struct Value*) (long) uid; 629 value = (struct Value*) (long) uid;
630 GNUNET_assert (NULL != value); 630 GNUNET_assert (NULL != value);
631 if (value->expiration.abs_value != expire.abs_value) 631 if (value->expiration.abs_value_us != expire.abs_value_us)
632 { 632 {
633 value->expiration = expire; 633 value->expiration = expire;
634 GNUNET_CONTAINER_heap_update_cost (plugin->by_expiration, 634 GNUNET_CONTAINER_heap_update_cost (plugin->by_expiration,
635 value->expire_heap, 635 value->expire_heap,
636 expire.abs_value); 636 expire.abs_value_us);
637 } 637 }
638 if ( (delta < 0) && (value->priority < - delta) ) 638 if ( (delta < 0) && (value->priority < - delta) )
639 value->priority = 0; 639 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,
290 unsigned int irepl = replication; 290 unsigned int irepl = replication;
291 unsigned int ipriority = priority; 291 unsigned int ipriority = priority;
292 unsigned int ianonymity = anonymity; 292 unsigned int ianonymity = anonymity;
293 unsigned long long lexpiration = expiration.abs_value; 293 unsigned long long lexpiration = expiration.abs_value_us;
294 unsigned long long lrvalue = 294 unsigned long long lrvalue =
295 (unsigned long long) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 295 (unsigned long long) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
296 UINT64_MAX); 296 UINT64_MAX);
@@ -358,12 +358,13 @@ mysql_plugin_update (void *cls, uint64_t uid, int delta,
358{ 358{
359 struct Plugin *plugin = cls; 359 struct Plugin *plugin = cls;
360 unsigned long long vkey = uid; 360 unsigned long long vkey = uid;
361 unsigned long long lexpire = expire.abs_value; 361 unsigned long long lexpire = expire.abs_value_us;
362 int ret; 362 int ret;
363 363
364 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 364 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
365 "Updating value %llu adding %d to priority and maxing exp at %llu\n", 365 "Updating value %llu adding %d to priority and maxing exp at %s\n",
366 vkey, delta, lexpire); 366 vkey, delta,
367 GNUNET_STRINGS_absolute_time_to_string (expire));
367 ret = 368 ret =
368 GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->update_entry, NULL, 369 GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->update_entry, NULL,
369 MYSQL_TYPE_LONG, &delta, GNUNET_NO, 370 MYSQL_TYPE_LONG, &delta, GNUNET_NO,
@@ -449,11 +450,13 @@ execute_select (struct Plugin *plugin, struct GNUNET_MYSQL_StatementHandle *stmt
449 proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); 450 proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
450 return; 451 return;
451 } 452 }
453 expiration.abs_value_us = exp;
452 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 454 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
453 "Found %u-byte value under key `%s' with prio %u, anon %u, expire %llu selecting from gn090 table\n", 455 "Found %u-byte value under key `%s' with prio %u, anon %u, expire %s selecting from gn090 table\n",
454 (unsigned int) size, GNUNET_h2s (&key), priority, anonymity, exp); 456 (unsigned int) size, GNUNET_h2s (&key),
457 priority, anonymity,
458 GNUNET_STRINGS_absolute_time_to_string (expiration));
455 GNUNET_assert (size < MAX_DATUM_SIZE); 459 GNUNET_assert (size < MAX_DATUM_SIZE);
456 expiration.abs_value = exp;
457 ret = 460 ret =
458 proc (proc_cls, &key, size, value, type, priority, anonymity, expiration, 461 proc (proc_cls, &key, size, value, type, priority, anonymity, expiration,
459 uid); 462 uid);
@@ -907,7 +910,7 @@ mysql_plugin_get_expiration (void *cls, PluginDatumProcessor proc,
907 rc.plugin = plugin; 910 rc.plugin = plugin;
908 rc.proc = proc; 911 rc.proc = proc;
909 rc.proc_cls = proc_cls; 912 rc.proc_cls = proc_cls;
910 nt = (long long) GNUNET_TIME_absolute_get ().abs_value; 913 nt = (long long) GNUNET_TIME_absolute_get ().abs_value_us;
911 execute_select (plugin, plugin->select_expiration, expi_proc, &rc, 914 execute_select (plugin, plugin->select_expiration, expi_proc, &rc,
912 MYSQL_TYPE_LONGLONG, &nt, GNUNET_YES, -1); 915 MYSQL_TYPE_LONGLONG, &nt, GNUNET_YES, -1);
913 916
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 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2009, 2010, 2011, 2012 Christian Grothoff (and other contributing authors) 3 (C) 2009-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 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
283 uint32_t bprio = htonl (priority); 283 uint32_t bprio = htonl (priority);
284 uint32_t banon = htonl (anonymity); 284 uint32_t banon = htonl (anonymity);
285 uint32_t brepl = htonl (replication); 285 uint32_t brepl = htonl (replication);
286 uint64_t bexpi = GNUNET_TIME_absolute_hton (expiration).abs_value__; 286 uint64_t bexpi = GNUNET_TIME_absolute_hton (expiration).abs_value_us__;
287 287
288 const char *paramValues[] = { 288 const char *paramValues[] = {
289 (const char *) &brepl, 289 (const char *) &brepl,
@@ -392,7 +392,7 @@ process_result (struct Plugin *plugin, PluginDatumProcessor proc,
392 type = ntohl (*(uint32_t *) PQgetvalue (res, 0, 0)); 392 type = ntohl (*(uint32_t *) PQgetvalue (res, 0, 0));
393 priority = ntohl (*(uint32_t *) PQgetvalue (res, 0, 1)); 393 priority = ntohl (*(uint32_t *) PQgetvalue (res, 0, 1));
394 anonymity = ntohl (*(uint32_t *) PQgetvalue (res, 0, 2)); 394 anonymity = ntohl (*(uint32_t *) PQgetvalue (res, 0, 2));
395 expiration_time.abs_value = 395 expiration_time.abs_value_us =
396 GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, 0, 3)); 396 GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, 0, 3));
397 memcpy (&key, PQgetvalue (res, 0, 4), sizeof (struct GNUNET_HashCode)); 397 memcpy (&key, PQgetvalue (res, 0, 4), sizeof (struct GNUNET_HashCode));
398 size = PQgetlength (res, 0, 5); 398 size = PQgetlength (res, 0, 5);
@@ -712,7 +712,7 @@ postgres_plugin_get_expiration (void *cls, PluginDatumProcessor proc,
712 const char *paramValues[] = { (const char *) &btime }; 712 const char *paramValues[] = { (const char *) &btime };
713 PGresult *ret; 713 PGresult *ret;
714 714
715 btime = GNUNET_htonll (GNUNET_TIME_absolute_get ().abs_value); 715 btime = GNUNET_htonll (GNUNET_TIME_absolute_get ().abs_value_us);
716 ret = 716 ret =
717 PQexecPrepared (plugin->dbh, "select_expiration_order", 1, paramValues, 717 PQexecPrepared (plugin->dbh, "select_expiration_order", 1, paramValues,
718 paramLengths, paramFormats, 1); 718 paramLengths, paramFormats, 1);
@@ -751,7 +751,7 @@ postgres_plugin_update (void *cls, uint64_t uid, int delta,
751 PGresult *ret; 751 PGresult *ret;
752 int32_t bdelta = (int32_t) htonl ((uint32_t) delta); 752 int32_t bdelta = (int32_t) htonl ((uint32_t) delta);
753 uint32_t boid = htonl ((uint32_t) uid); 753 uint32_t boid = htonl ((uint32_t) uid);
754 uint64_t bexpire = GNUNET_TIME_absolute_hton (expire).abs_value__; 754 uint64_t bexpire = GNUNET_TIME_absolute_hton (expire).abs_value_us__;
755 755
756 const char *paramValues[] = { 756 const char *paramValues[] = {
757 (const char *) &bdelta, 757 (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,
488 if (size > MAX_ITEM_SIZE) 488 if (size > MAX_ITEM_SIZE)
489 return GNUNET_SYSERR; 489 return GNUNET_SYSERR;
490 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", 490 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
491 "Storing in database block with type %u/key `%s'/priority %u/expiration in %llu ms (%lld).\n", 491 "Storing in database block with type %u/key `%s'/priority %u/expiration in %s (%s).\n",
492 type, GNUNET_h2s (key), priority, 492 type, GNUNET_h2s (key), priority,
493 (unsigned long long) 493 (unsigned long long)
494 GNUNET_TIME_absolute_get_remaining (expiration).rel_value, 494 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration),
495 (long long) expiration.abs_value); 495 GNUNET_YES),
496 GNUNET_STRINGS_absolute_time_to_string (expiration));
496 GNUNET_CRYPTO_hash (data, size, &vhash); 497 GNUNET_CRYPTO_hash (data, size, &vhash);
497 stmt = plugin->insertContent; 498 stmt = plugin->insertContent;
498 rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); 499 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,
500 (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) || 501 (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) ||
501 (SQLITE_OK != sqlite3_bind_int (stmt, 3, priority)) || 502 (SQLITE_OK != sqlite3_bind_int (stmt, 3, priority)) ||
502 (SQLITE_OK != sqlite3_bind_int (stmt, 4, anonymity)) || 503 (SQLITE_OK != sqlite3_bind_int (stmt, 4, anonymity)) ||
503 (SQLITE_OK != sqlite3_bind_int64 (stmt, 5, expiration.abs_value)) || 504 (SQLITE_OK != sqlite3_bind_int64 (stmt, 5, expiration.abs_value_us)) ||
504 (SQLITE_OK != sqlite3_bind_int64 (stmt, 6, rvalue)) || 505 (SQLITE_OK != sqlite3_bind_int64 (stmt, 6, rvalue)) ||
505 (SQLITE_OK != 506 (SQLITE_OK !=
506 sqlite3_bind_blob (stmt, 7, key, sizeof (struct GNUNET_HashCode), 507 sqlite3_bind_blob (stmt, 7, key, sizeof (struct GNUNET_HashCode),
@@ -583,7 +584,7 @@ sqlite_plugin_update (void *cls, uint64_t uid, int delta,
583 int n; 584 int n;
584 585
585 if ((SQLITE_OK != sqlite3_bind_int (plugin->updPrio, 1, delta)) || 586 if ((SQLITE_OK != sqlite3_bind_int (plugin->updPrio, 1, delta)) ||
586 (SQLITE_OK != sqlite3_bind_int64 (plugin->updPrio, 2, expire.abs_value)) 587 (SQLITE_OK != sqlite3_bind_int64 (plugin->updPrio, 2, expire.abs_value_us))
587 || (SQLITE_OK != sqlite3_bind_int64 (plugin->updPrio, 3, uid))) 588 || (SQLITE_OK != sqlite3_bind_int64 (plugin->updPrio, 3, uid)))
588 { 589 {
589 LOG_SQLITE (plugin, msg, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 590 LOG_SQLITE (plugin, msg, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
@@ -655,10 +656,10 @@ execute_get (struct Plugin *plugin, sqlite3_stmt * stmt,
655 -(size + GNUNET_DATASTORE_ENTRY_OVERHEAD)); 656 -(size + GNUNET_DATASTORE_ENTRY_OVERHEAD));
656 break; 657 break;
657 } 658 }
658 expiration.abs_value = sqlite3_column_int64 (stmt, 3); 659 expiration.abs_value_us = sqlite3_column_int64 (stmt, 3);
659 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", 660 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
660 "Found reply in database with expiration %llu\n", 661 "Found reply in database with expiration %s\n",
661 (unsigned long long) expiration.abs_value); 662 GNUNET_STRINGS_absolute_time_to_string (expiration));
662 ret = proc (proc_cls, sqlite3_column_blob (stmt, 4) /* key */ , 663 ret = proc (proc_cls, sqlite3_column_blob (stmt, 4) /* key */ ,
663 size, sqlite3_column_blob (stmt, 5) /* data */ , 664 size, sqlite3_column_blob (stmt, 5) /* data */ ,
664 sqlite3_column_int (stmt, 0) /* type */ , 665 sqlite3_column_int (stmt, 0) /* type */ ,
@@ -1040,7 +1041,7 @@ sqlite_plugin_get_expiration (void *cls, PluginDatumProcessor proc,
1040 "Getting random block based on expiration and priority order.\n"); 1041 "Getting random block based on expiration and priority order.\n");
1041 now = GNUNET_TIME_absolute_get (); 1042 now = GNUNET_TIME_absolute_get ();
1042 stmt = plugin->selExpi; 1043 stmt = plugin->selExpi;
1043 if (SQLITE_OK != sqlite3_bind_int64 (stmt, 1, now.abs_value)) 1044 if (SQLITE_OK != sqlite3_bind_int64 (stmt, 1, now.abs_value_us))
1044 { 1045 {
1045 LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 1046 LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
1046 "sqlite3_bind_XXXX"); 1047 "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)
94{ 94{
95 struct GNUNET_TIME_Absolute av; 95 struct GNUNET_TIME_Absolute av;
96 96
97 av.abs_value = now.abs_value + 20000000 - i * 1000; 97 av.abs_value_us = now.abs_value_us + 20000000000LL - i * 1000 * 1000LL;
98 return av; 98 return av;
99} 99}
100 100
@@ -191,20 +191,21 @@ check_value (void *cls, const struct GNUNET_HashCode * key, size_t size,
191 return; 191 return;
192 } 192 }
193#if 0 193#if 0
194 FPRINTF (stderr, "Check value got `%s' of size %u, type %d, expire %llu\n", 194 FPRINTF (stderr,
195 "Check value got `%s' of size %u, type %d, expire %s\n",
195 GNUNET_h2s (key), (unsigned int) size, type, 196 GNUNET_h2s (key), (unsigned int) size, type,
196 (unsigned long long) expiration.abs_value); 197 GNUNET_STRINGS_absolute_time_to_string (expiration));
197 FPRINTF (stderr, 198 FPRINTF (stderr,
198 "Check value iteration %d wants size %u, type %d, expire %llu\n", i, 199 "Check value iteration %d wants size %u, type %d, expire %s\n", i,
199 (unsigned int) get_size (i), get_type (i), 200 (unsigned int) get_size (i), get_type (i),
200 (unsigned long long) get_expiration (i).abs_value); 201 GNUNET_STRINGS_absolute_time_to_string (get_expiration(i)));
201#endif 202#endif
202 GNUNET_assert (size == get_size (i)); 203 GNUNET_assert (size == get_size (i));
203 GNUNET_assert (0 == memcmp (data, get_data (i), size)); 204 GNUNET_assert (0 == memcmp (data, get_data (i), size));
204 GNUNET_assert (type == get_type (i)); 205 GNUNET_assert (type == get_type (i));
205 GNUNET_assert (priority == get_priority (i)); 206 GNUNET_assert (priority == get_priority (i));
206 GNUNET_assert (anonymity == get_anonymity (i)); 207 GNUNET_assert (anonymity == get_anonymity (i));
207 GNUNET_assert (expiration.abs_value == get_expiration (i).abs_value); 208 GNUNET_assert (expiration.abs_value_us == get_expiration (i).abs_value_us);
208 crc->offset++; 209 crc->offset++;
209 if (crc->i == 0) 210 if (crc->i == 0)
210 { 211 {
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)
113{ 113{
114 struct GNUNET_TIME_Absolute av; 114 struct GNUNET_TIME_Absolute av;
115 115
116 av.abs_value = now.abs_value + i * 1000; 116 av.abs_value_us = now.abs_value_us + i * 1000 * 1000LL;
117 return av; 117 return av;
118} 118}
119 119
@@ -159,7 +159,7 @@ check_value (void *cls, const struct GNUNET_HashCode * key, size_t size,
159 GNUNET_assert (type == get_type (i)); 159 GNUNET_assert (type == get_type (i));
160 GNUNET_assert (priority == get_priority (i)); 160 GNUNET_assert (priority == get_priority (i));
161 GNUNET_assert (anonymity == get_anonymity (i)); 161 GNUNET_assert (anonymity == get_anonymity (i));
162 GNUNET_assert (expiration.abs_value == get_expiration (i).abs_value); 162 GNUNET_assert (expiration.abs_value_us == get_expiration (i).abs_value_us);
163 crc->offset++; 163 crc->offset++;
164 crc->i--; 164 crc->i--;
165 if (crc->i == 0) 165 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,
158 guid = uid; 158 guid = uid;
159 crc->phase++; 159 crc->phase++;
160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
161 "Found result type=%u, priority=%u, size=%u, expire=%llu, key %s\n", 161 "Found result type=%u, priority=%u, size=%u, expire=%s, key %s\n",
162 type, priority, size, (unsigned long long) expiration.abs_value, 162 type, priority, size,
163 GNUNET_STRINGS_absolute_time_to_string (expiration),
163 GNUNET_h2s (key)); 164 GNUNET_h2s (key));
164 GNUNET_SCHEDULER_add_now (&test, crc); 165 GNUNET_SCHEDULER_add_now (&test, crc);
165 return GNUNET_OK; 166 return GNUNET_OK;