diff options
-rw-r--r-- | src/include/gnunet_namestore_plugin.h | 8 | ||||
-rw-r--r-- | src/namestore/gnunet-namestore-fcfsd.c | 9 | ||||
-rw-r--r-- | src/namestore/gnunet-namestore.c | 6 | ||||
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 43 | ||||
-rw-r--r-- | src/namestore/namestore.h | 4 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_flat.c | 17 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_postgres.c | 47 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_sqlite.c | 141 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_monitoring.c | 24 | ||||
-rw-r--r-- | src/namestore/test_plugin_namestore.c | 16 |
10 files changed, 201 insertions, 114 deletions
diff --git a/src/include/gnunet_namestore_plugin.h b/src/include/gnunet_namestore_plugin.h index 802d7bac5..c3ab4d8bf 100644 --- a/src/include/gnunet_namestore_plugin.h +++ b/src/include/gnunet_namestore_plugin.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2012, 2013 GNUnet e.V. | 3 | Copyright (C) 2012, 2013, 2018 GNUnet e.V. |
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 |
@@ -47,6 +47,7 @@ extern "C" | |||
47 | * Function called for each matching record. | 47 | * Function called for each matching record. |
48 | * | 48 | * |
49 | * @param cls closure | 49 | * @param cls closure |
50 | * @param serial unique serial number of the record | ||
50 | * @param zone_key private key of the zone | 51 | * @param zone_key private key of the zone |
51 | * @param label name that is being mapped (at most 255 characters long) | 52 | * @param label name that is being mapped (at most 255 characters long) |
52 | * @param rd_count number of entries in @a rd array | 53 | * @param rd_count number of entries in @a rd array |
@@ -54,6 +55,7 @@ extern "C" | |||
54 | */ | 55 | */ |
55 | typedef void | 56 | typedef void |
56 | (*GNUNET_NAMESTORE_RecordIterator) (void *cls, | 57 | (*GNUNET_NAMESTORE_RecordIterator) (void *cls, |
58 | uint64_t serial, | ||
57 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, | 59 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, |
58 | const char *label, | 60 | const char *label, |
59 | unsigned int rd_count, | 61 | unsigned int rd_count, |
@@ -113,7 +115,7 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
113 | * | 115 | * |
114 | * @param cls closure (internal context for the plugin) | 116 | * @param cls closure (internal context for the plugin) |
115 | * @param zone private key of the zone, NULL for all zones | 117 | * @param zone private key of the zone, NULL for all zones |
116 | * @param offset offset in the list of all matching records | 118 | * @param serial serial (to exclude) in the list of matching records |
117 | * @param limit maximum number of results to return to @a iter | 119 | * @param limit maximum number of results to return to @a iter |
118 | * @param iter function to call with the result | 120 | * @param iter function to call with the result |
119 | * @param iter_cls closure for @a iter | 121 | * @param iter_cls closure for @a iter |
@@ -122,7 +124,7 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
122 | int | 124 | int |
123 | (*iterate_records) (void *cls, | 125 | (*iterate_records) (void *cls, |
124 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 126 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
125 | uint64_t offset, | 127 | uint64_t serial, |
126 | uint64_t limit, | 128 | uint64_t limit, |
127 | GNUNET_NAMESTORE_RecordIterator iter, | 129 | GNUNET_NAMESTORE_RecordIterator iter, |
128 | void *iter_cls); | 130 | void *iter_cls); |
diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c index 6e45f8227..903253b1a 100644 --- a/src/namestore/gnunet-namestore-fcfsd.c +++ b/src/namestore/gnunet-namestore-fcfsd.c | |||
@@ -324,6 +324,7 @@ iterate_cb (void *cls, | |||
324 | char* pkey; | 324 | char* pkey; |
325 | char* new_buf; | 325 | char* new_buf; |
326 | 326 | ||
327 | (void) zone_key; | ||
327 | if (1 != rd_len) | 328 | if (1 != rd_len) |
328 | { | 329 | { |
329 | GNUNET_NAMESTORE_zone_iterator_next (zr->list_it, | 330 | GNUNET_NAMESTORE_zone_iterator_next (zr->list_it, |
@@ -439,6 +440,7 @@ fill_s_reply (const char *info, | |||
439 | char *reply; | 440 | char *reply; |
440 | struct MHD_Response *response; | 441 | struct MHD_Response *response; |
441 | 442 | ||
443 | (void) request; | ||
442 | GNUNET_asprintf (&reply, | 444 | GNUNET_asprintf (&reply, |
443 | SUBMIT_PAGE, | 445 | SUBMIT_PAGE, |
444 | info, | 446 | info, |
@@ -587,6 +589,8 @@ zone_to_name_cb (void *cls, | |||
587 | struct Request *request = cls; | 589 | struct Request *request = cls; |
588 | struct GNUNET_GNSRECORD_Data r; | 590 | struct GNUNET_GNSRECORD_Data r; |
589 | 591 | ||
592 | (void) rd; | ||
593 | (void) zone_key; | ||
590 | request->qe = NULL; | 594 | request->qe = NULL; |
591 | if (0 != rd_count) | 595 | if (0 != rd_count) |
592 | { | 596 | { |
@@ -644,6 +648,9 @@ lookup_block_processor (void *cls, | |||
644 | { | 648 | { |
645 | struct Request *request = cls; | 649 | struct Request *request = cls; |
646 | 650 | ||
651 | (void) label; | ||
652 | (void) rd; | ||
653 | (void) zone; | ||
647 | request->qe = NULL; | 654 | request->qe = NULL; |
648 | if (0 == rd_count) | 655 | if (0 == rd_count) |
649 | { | 656 | { |
@@ -715,6 +722,8 @@ create_response (void *cls, | |||
715 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; | 722 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; |
716 | int ret; | 723 | int ret; |
717 | 724 | ||
725 | (void) cls; | ||
726 | (void) version; | ||
718 | if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) || | 727 | if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) || |
719 | (0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) ) | 728 | (0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) ) |
720 | { | 729 | { |
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 7b8312b46..d329dcb3b 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -661,6 +661,8 @@ handle_reverse_lookup (void *cls, | |||
661 | { | 661 | { |
662 | (void) cls; | 662 | (void) cls; |
663 | (void) zone; | 663 | (void) zone; |
664 | (void) rd_count; | ||
665 | (void) rd; | ||
664 | reverse_qe = NULL; | 666 | reverse_qe = NULL; |
665 | if (NULL == label) | 667 | if (NULL == label) |
666 | FPRINTF (stdout, | 668 | FPRINTF (stdout, |
@@ -712,6 +714,7 @@ del_monitor (void *cls, | |||
712 | char *vs; | 714 | char *vs; |
713 | 715 | ||
714 | (void) cls; | 716 | (void) cls; |
717 | (void) zone; | ||
715 | del_qe = NULL; | 718 | del_qe = NULL; |
716 | if (0 == rd_count) | 719 | if (0 == rd_count) |
717 | { | 720 | { |
@@ -1092,6 +1095,9 @@ id_connect_cb (void *cls, | |||
1092 | { | 1095 | { |
1093 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 1096 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
1094 | 1097 | ||
1098 | (void) cls; | ||
1099 | (void) ctx; | ||
1100 | (void) name; | ||
1095 | if (NULL == ego) | 1101 | if (NULL == ego) |
1096 | { | 1102 | { |
1097 | get_default = GNUNET_IDENTITY_get (idh, | 1103 | get_default = GNUNET_IDENTITY_get (idh, |
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index c6bab15b7..6b8f73242 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -75,6 +75,15 @@ struct ZoneIteration | |||
75 | struct GNUNET_CRYPTO_EcdsaPrivateKey zone; | 75 | struct GNUNET_CRYPTO_EcdsaPrivateKey zone; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Last sequence number in the zone iteration used to address next | ||
79 | * result of the zone iteration in the store | ||
80 | * | ||
81 | * Initialy set to 0. | ||
82 | * Updated in #zone_iterate_proc() | ||
83 | */ | ||
84 | uint64_t seq; | ||
85 | |||
86 | /** | ||
78 | * The operation id fot the zone iteration in the response for the client | 87 | * The operation id fot the zone iteration in the response for the client |
79 | */ | 88 | */ |
80 | uint32_t request_id; | 89 | uint32_t request_id; |
@@ -152,13 +161,13 @@ struct ZoneMonitor | |||
152 | struct GNUNET_SCHEDULER_Task *task; | 161 | struct GNUNET_SCHEDULER_Task *task; |
153 | 162 | ||
154 | /** | 163 | /** |
155 | * Offset of the zone iteration used to address next result of the zone | 164 | * Last sequence number in the zone iteration used to address next |
156 | * iteration in the store | 165 | * result of the zone iteration in the store |
157 | * | 166 | * |
158 | * Initialy set to 0. | 167 | * Initialy set to 0. |
159 | * Incremented with by every call to #handle_iteration_next | 168 | * Updated in #monitor_iterate_cb() |
160 | */ | 169 | */ |
161 | uint32_t offset; | 170 | uint64_t seq; |
162 | 171 | ||
163 | }; | 172 | }; |
164 | 173 | ||
@@ -394,6 +403,7 @@ client_connect_cb (void *cls, | |||
394 | * record, which (if found) is then copied to @a cls for future use. | 403 | * record, which (if found) is then copied to @a cls for future use. |
395 | * | 404 | * |
396 | * @param cls a `struct GNUNET_GNSRECORD_Data **` for storing the nick (if found) | 405 | * @param cls a `struct GNUNET_GNSRECORD_Data **` for storing the nick (if found) |
406 | * @param seq sequence number of the record | ||
397 | * @param private_key the private key of the zone (unused) | 407 | * @param private_key the private key of the zone (unused) |
398 | * @param label should be #GNUNET_GNS_EMPTY_LABEL_AT | 408 | * @param label should be #GNUNET_GNS_EMPTY_LABEL_AT |
399 | * @param rd_count number of records in @a rd | 409 | * @param rd_count number of records in @a rd |
@@ -401,6 +411,7 @@ client_connect_cb (void *cls, | |||
401 | */ | 411 | */ |
402 | static void | 412 | static void |
403 | lookup_nick_it (void *cls, | 413 | lookup_nick_it (void *cls, |
414 | uint64_t seq, | ||
404 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, | 415 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, |
405 | const char *label, | 416 | const char *label, |
406 | unsigned int rd_count, | 417 | unsigned int rd_count, |
@@ -409,6 +420,7 @@ lookup_nick_it (void *cls, | |||
409 | struct GNUNET_GNSRECORD_Data **res = cls; | 420 | struct GNUNET_GNSRECORD_Data **res = cls; |
410 | 421 | ||
411 | (void) private_key; | 422 | (void) private_key; |
423 | (void) seq; | ||
412 | if (0 != strcmp (label, GNUNET_GNS_EMPTY_LABEL_AT)) | 424 | if (0 != strcmp (label, GNUNET_GNS_EMPTY_LABEL_AT)) |
413 | { | 425 | { |
414 | GNUNET_break (0); | 426 | GNUNET_break (0); |
@@ -813,9 +825,11 @@ struct RecordLookupContext | |||
813 | 825 | ||
814 | /** | 826 | /** |
815 | * FIXME. | 827 | * FIXME. |
828 | * @param seq sequence number of the record | ||
816 | */ | 829 | */ |
817 | static void | 830 | static void |
818 | lookup_it (void *cls, | 831 | lookup_it (void *cls, |
832 | uint64_t seq, | ||
819 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, | 833 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, |
820 | const char *label, | 834 | const char *label, |
821 | unsigned int rd_count, | 835 | unsigned int rd_count, |
@@ -826,6 +840,7 @@ lookup_it (void *cls, | |||
826 | unsigned int rdc_res; | 840 | unsigned int rdc_res; |
827 | 841 | ||
828 | (void) private_key; | 842 | (void) private_key; |
843 | (void) seq; | ||
829 | if (0 == strcmp (label, | 844 | if (0 == strcmp (label, |
830 | rlc->label)) | 845 | rlc->label)) |
831 | { | 846 | { |
@@ -1212,6 +1227,7 @@ struct ZoneToNameCtx | |||
1212 | * Zone to name iterator | 1227 | * Zone to name iterator |
1213 | * | 1228 | * |
1214 | * @param cls struct ZoneToNameCtx * | 1229 | * @param cls struct ZoneToNameCtx * |
1230 | * @param seq sequence number of the record | ||
1215 | * @param zone_key the zone key | 1231 | * @param zone_key the zone key |
1216 | * @param name name | 1232 | * @param name name |
1217 | * @param rd_count number of records in @a rd | 1233 | * @param rd_count number of records in @a rd |
@@ -1219,6 +1235,7 @@ struct ZoneToNameCtx | |||
1219 | */ | 1235 | */ |
1220 | static void | 1236 | static void |
1221 | handle_zone_to_name_it (void *cls, | 1237 | handle_zone_to_name_it (void *cls, |
1238 | uint64_t seq, | ||
1222 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 1239 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
1223 | const char *name, | 1240 | const char *name, |
1224 | unsigned int rd_count, | 1241 | unsigned int rd_count, |
@@ -1234,6 +1251,7 @@ handle_zone_to_name_it (void *cls, | |||
1234 | char *name_tmp; | 1251 | char *name_tmp; |
1235 | char *rd_tmp; | 1252 | char *rd_tmp; |
1236 | 1253 | ||
1254 | (void) seq; | ||
1237 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1255 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1238 | "Found result for zone-to-name lookup: `%s'\n", | 1256 | "Found result for zone-to-name lookup: `%s'\n", |
1239 | name); | 1257 | name); |
@@ -1342,8 +1360,9 @@ struct ZoneIterationProcResult | |||
1342 | 1360 | ||
1343 | /** | 1361 | /** |
1344 | * Process results for zone iteration from database | 1362 | * Process results for zone iteration from database |
1345 | * | 1363 | * |
1346 | * @param cls struct ZoneIterationProcResult *proc | 1364 | * @param cls struct ZoneIterationProcResult |
1365 | * @param seq sequence number of the record | ||
1347 | * @param zone_key the zone key | 1366 | * @param zone_key the zone key |
1348 | * @param name name | 1367 | * @param name name |
1349 | * @param rd_count number of records for this name | 1368 | * @param rd_count number of records for this name |
@@ -1351,6 +1370,7 @@ struct ZoneIterationProcResult | |||
1351 | */ | 1370 | */ |
1352 | static void | 1371 | static void |
1353 | zone_iterate_proc (void *cls, | 1372 | zone_iterate_proc (void *cls, |
1373 | uint64_t seq, | ||
1354 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 1374 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
1355 | const char *name, | 1375 | const char *name, |
1356 | unsigned int rd_count, | 1376 | unsigned int rd_count, |
@@ -1380,6 +1400,7 @@ zone_iterate_proc (void *cls, | |||
1380 | return; | 1400 | return; |
1381 | } | 1401 | } |
1382 | proc->limit--; | 1402 | proc->limit--; |
1403 | proc->zi->seq = seq; | ||
1383 | send_lookup_response (proc->zi->nc, | 1404 | send_lookup_response (proc->zi->nc, |
1384 | proc->zi->request_id, | 1405 | proc->zi->request_id, |
1385 | zone_key, | 1406 | zone_key, |
@@ -1432,7 +1453,7 @@ run_zone_iteration_round (struct ZoneIteration *zi, | |||
1432 | sizeof (zero))) | 1453 | sizeof (zero))) |
1433 | ? NULL | 1454 | ? NULL |
1434 | : &zi->zone, | 1455 | : &zi->zone, |
1435 | zi->offset, | 1456 | zi->seq, |
1436 | limit, | 1457 | limit, |
1437 | &zone_iterate_proc, | 1458 | &zone_iterate_proc, |
1438 | &proc)); | 1459 | &proc)); |
@@ -1443,7 +1464,6 @@ run_zone_iteration_round (struct ZoneIteration *zi, | |||
1443 | "NAMESTORE iteration delay (μs/record)", | 1464 | "NAMESTORE iteration delay (μs/record)", |
1444 | duration.rel_value_us, | 1465 | duration.rel_value_us, |
1445 | GNUNET_NO); | 1466 | GNUNET_NO); |
1446 | zi->offset += (limit - proc.limit); | ||
1447 | if (0 == proc.limit) | 1467 | if (0 == proc.limit) |
1448 | { | 1468 | { |
1449 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1469 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1597,6 +1617,7 @@ monitor_next (void *cls); | |||
1597 | * A #GNUNET_NAMESTORE_RecordIterator for monitors. | 1617 | * A #GNUNET_NAMESTORE_RecordIterator for monitors. |
1598 | * | 1618 | * |
1599 | * @param cls a 'struct ZoneMonitor *' with information about the monitor | 1619 | * @param cls a 'struct ZoneMonitor *' with information about the monitor |
1620 | * @param seq sequence number of the record | ||
1600 | * @param zone_key zone key of the zone | 1621 | * @param zone_key zone key of the zone |
1601 | * @param name name | 1622 | * @param name name |
1602 | * @param rd_count number of records in @a rd | 1623 | * @param rd_count number of records in @a rd |
@@ -1604,6 +1625,7 @@ monitor_next (void *cls); | |||
1604 | */ | 1625 | */ |
1605 | static void | 1626 | static void |
1606 | monitor_iterate_cb (void *cls, | 1627 | monitor_iterate_cb (void *cls, |
1628 | uint64_t seq, | ||
1607 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 1629 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
1608 | const char *name, | 1630 | const char *name, |
1609 | unsigned int rd_count, | 1631 | unsigned int rd_count, |
@@ -1611,6 +1633,7 @@ monitor_iterate_cb (void *cls, | |||
1611 | { | 1633 | { |
1612 | struct ZoneMonitor *zm = cls; | 1634 | struct ZoneMonitor *zm = cls; |
1613 | 1635 | ||
1636 | zm->seq = seq; | ||
1614 | if (NULL == name) | 1637 | if (NULL == name) |
1615 | { | 1638 | { |
1616 | /* finished with iteration */ | 1639 | /* finished with iteration */ |
@@ -1683,7 +1706,7 @@ monitor_next (void *cls) | |||
1683 | sizeof (zero))) | 1706 | sizeof (zero))) |
1684 | ? NULL | 1707 | ? NULL |
1685 | : &zm->zone, | 1708 | : &zm->zone, |
1686 | zm->offset++, | 1709 | zm->seq, |
1687 | 1, | 1710 | 1, |
1688 | &monitor_iterate_cb, | 1711 | &monitor_iterate_cb, |
1689 | zm); | 1712 | zm); |
@@ -1727,7 +1750,7 @@ run (void *cls, | |||
1727 | "DISABLE"); | 1750 | "DISABLE"); |
1728 | GSN_cfg = cfg; | 1751 | GSN_cfg = cfg; |
1729 | monitor_nc = GNUNET_notification_context_create (1); | 1752 | monitor_nc = GNUNET_notification_context_create (1); |
1730 | if (GNUNET_NO == disable_namecache) | 1753 | if (GNUNET_YES != disable_namecache) |
1731 | { | 1754 | { |
1732 | namecache = GNUNET_NAMECACHE_connect (cfg); | 1755 | namecache = GNUNET_NAMECACHE_connect (cfg); |
1733 | GNUNET_assert (NULL != namecache); | 1756 | GNUNET_assert (NULL != namecache); |
diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h index b398af8a9..207b35662 100644 --- a/src/namestore/namestore.h +++ b/src/namestore/namestore.h | |||
@@ -161,7 +161,7 @@ struct LabelLookupResponseMessage | |||
161 | * Length of serialized record data | 161 | * Length of serialized record data |
162 | */ | 162 | */ |
163 | uint16_t rd_len GNUNET_PACKED; | 163 | uint16_t rd_len GNUNET_PACKED; |
164 | 164 | ||
165 | /** | 165 | /** |
166 | * Number of records contained | 166 | * Number of records contained |
167 | */ | 167 | */ |
@@ -169,7 +169,7 @@ struct LabelLookupResponseMessage | |||
169 | 169 | ||
170 | /** | 170 | /** |
171 | * Was the label found in the database?? | 171 | * Was the label found in the database?? |
172 | * GNUNET_YES or GNUNET_NO | 172 | * #GNUNET_YES or #GNUNET_NO |
173 | */ | 173 | */ |
174 | uint16_t found GNUNET_PACKED; | 174 | uint16_t found GNUNET_PACKED; |
175 | 175 | ||
diff --git a/src/namestore/plugin_namestore_flat.c b/src/namestore/plugin_namestore_flat.c index f061ab7d1..f40154915 100644 --- a/src/namestore/plugin_namestore_flat.c +++ b/src/namestore/plugin_namestore_flat.c | |||
@@ -523,6 +523,7 @@ namestore_flat_lookup_records (void *cls, | |||
523 | return GNUNET_NO; | 523 | return GNUNET_NO; |
524 | if (NULL != iter) | 524 | if (NULL != iter) |
525 | iter (iter_cls, | 525 | iter (iter_cls, |
526 | 0, | ||
526 | entry->private_key, | 527 | entry->private_key, |
527 | entry->label, | 528 | entry->label, |
528 | entry->record_count, | 529 | entry->record_count, |
@@ -547,6 +548,12 @@ struct IterateContext | |||
547 | uint64_t limit; | 548 | uint64_t limit; |
548 | 549 | ||
549 | /** | 550 | /** |
551 | * What is the position of the current entry, counting | ||
552 | * starts from 1. | ||
553 | */ | ||
554 | uint64_t pos; | ||
555 | |||
556 | /** | ||
550 | * Target zone. | 557 | * Target zone. |
551 | */ | 558 | */ |
552 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone; | 559 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone; |
@@ -581,6 +588,7 @@ iterate_zones (void *cls, | |||
581 | struct FlatFileEntry *entry = value; | 588 | struct FlatFileEntry *entry = value; |
582 | 589 | ||
583 | (void) key; | 590 | (void) key; |
591 | ic->pos++; | ||
584 | if (0 == ic->limit) | 592 | if (0 == ic->limit) |
585 | return GNUNET_NO; | 593 | return GNUNET_NO; |
586 | if ( (NULL != ic->zone) && | 594 | if ( (NULL != ic->zone) && |
@@ -594,6 +602,7 @@ iterate_zones (void *cls, | |||
594 | return GNUNET_YES; | 602 | return GNUNET_YES; |
595 | } | 603 | } |
596 | ic->iter (ic->iter_cls, | 604 | ic->iter (ic->iter_cls, |
605 | ic->pos, | ||
597 | entry->private_key, | 606 | entry->private_key, |
598 | entry->label, | 607 | entry->label, |
599 | entry->record_count, | 608 | entry->record_count, |
@@ -611,7 +620,7 @@ iterate_zones (void *cls, | |||
611 | * | 620 | * |
612 | * @param cls closure (internal context for the plugin) | 621 | * @param cls closure (internal context for the plugin) |
613 | * @param zone hash of public key of the zone, NULL to iterate over all zones | 622 | * @param zone hash of public key of the zone, NULL to iterate over all zones |
614 | * @param offset offset in the list of all matching records | 623 | * @param serial serial number to exclude in the list of all matching records |
615 | * @param limit maximum number of results to return to @a iter | 624 | * @param limit maximum number of results to return to @a iter |
616 | * @param iter function to call with the result | 625 | * @param iter function to call with the result |
617 | * @param iter_cls closure for @a iter | 626 | * @param iter_cls closure for @a iter |
@@ -620,7 +629,7 @@ iterate_zones (void *cls, | |||
620 | static int | 629 | static int |
621 | namestore_flat_iterate_records (void *cls, | 630 | namestore_flat_iterate_records (void *cls, |
622 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 631 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
623 | uint64_t offset, | 632 | uint64_t serial, |
624 | uint64_t limit, | 633 | uint64_t limit, |
625 | GNUNET_NAMESTORE_RecordIterator iter, | 634 | GNUNET_NAMESTORE_RecordIterator iter, |
626 | void *iter_cls) | 635 | void *iter_cls) |
@@ -628,7 +637,8 @@ namestore_flat_iterate_records (void *cls, | |||
628 | struct Plugin *plugin = cls; | 637 | struct Plugin *plugin = cls; |
629 | struct IterateContext ic; | 638 | struct IterateContext ic; |
630 | 639 | ||
631 | ic.offset = offset; | 640 | ic.offset = serial; |
641 | ic.pos = 0; | ||
632 | ic.limit = limit; | 642 | ic.limit = limit; |
633 | ic.iter = iter; | 643 | ic.iter = iter; |
634 | ic.iter_cls = iter_cls; | 644 | ic.iter_cls = iter_cls; |
@@ -663,6 +673,7 @@ zone_to_name (void *cls, | |||
663 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | 673 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) |
664 | { | 674 | { |
665 | plugin->iter (plugin->iter_cls, | 675 | plugin->iter (plugin->iter_cls, |
676 | 0, | ||
666 | entry->private_key, | 677 | entry->private_key, |
667 | entry->label, | 678 | entry->label, |
668 | entry->record_count, | 679 | entry->record_count, |
diff --git a/src/namestore/plugin_namestore_postgres.c b/src/namestore/plugin_namestore_postgres.c index 4a24ddf88..42bc9e4c9 100644 --- a/src/namestore/plugin_namestore_postgres.c +++ b/src/namestore/plugin_namestore_postgres.c | |||
@@ -65,7 +65,8 @@ static int | |||
65 | database_setup (struct Plugin *plugin) | 65 | database_setup (struct Plugin *plugin) |
66 | { | 66 | { |
67 | struct GNUNET_PQ_ExecuteStatement es_temporary = | 67 | struct GNUNET_PQ_ExecuteStatement es_temporary = |
68 | GNUNET_PQ_make_execute ("CREATE TEMPORARY TABLE IF NOT EXISTS ns097records (" | 68 | GNUNET_PQ_make_execute ("CREATE TEMPORARY TABLE IF NOT EXISTS ns098records (" |
69 | " seq BIGSERIAL PRIMARY KEY," | ||
69 | " zone_private_key BYTEA NOT NULL DEFAULT ''," | 70 | " zone_private_key BYTEA NOT NULL DEFAULT ''," |
70 | " pkey BYTEA DEFAULT ''," | 71 | " pkey BYTEA DEFAULT ''," |
71 | " rvalue BYTEA NOT NULL DEFAULT ''," | 72 | " rvalue BYTEA NOT NULL DEFAULT ''," |
@@ -75,7 +76,8 @@ database_setup (struct Plugin *plugin) | |||
75 | ")" | 76 | ")" |
76 | "WITH OIDS"); | 77 | "WITH OIDS"); |
77 | struct GNUNET_PQ_ExecuteStatement es_default = | 78 | struct GNUNET_PQ_ExecuteStatement es_default = |
78 | GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS ns097records (" | 79 | GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS ns098records (" |
80 | " seq SERIAL PRIMARY KEY," | ||
79 | " zone_private_key BYTEA NOT NULL DEFAULT ''," | 81 | " zone_private_key BYTEA NOT NULL DEFAULT ''," |
80 | " pkey BYTEA DEFAULT ''," | 82 | " pkey BYTEA DEFAULT ''," |
81 | " rvalue BYTEA NOT NULL DEFAULT ''," | 83 | " rvalue BYTEA NOT NULL DEFAULT ''," |
@@ -125,13 +127,11 @@ database_setup (struct Plugin *plugin) | |||
125 | struct GNUNET_PQ_ExecuteStatement es[] = { | 127 | struct GNUNET_PQ_ExecuteStatement es[] = { |
126 | *cr, | 128 | *cr, |
127 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_reverse " | 129 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_reverse " |
128 | "ON ns097records (zone_private_key,pkey)"), | 130 | "ON ns098records (zone_private_key,pkey)"), |
129 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_iter " | 131 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_iter " |
130 | "ON ns097records (zone_private_key,rvalue)"), | 132 | "ON ns098records (zone_private_key,seq)"), |
131 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS it_iter " | ||
132 | "ON ns097records (rvalue)"), | ||
133 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_label " | 133 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_label " |
134 | "ON ns097records (label)"), | 134 | "ON ns098records (label)"), |
135 | GNUNET_PQ_EXECUTE_STATEMENT_END | 135 | GNUNET_PQ_EXECUTE_STATEMENT_END |
136 | }; | 136 | }; |
137 | 137 | ||
@@ -148,28 +148,28 @@ database_setup (struct Plugin *plugin) | |||
148 | { | 148 | { |
149 | struct GNUNET_PQ_PreparedStatement ps[] = { | 149 | struct GNUNET_PQ_PreparedStatement ps[] = { |
150 | GNUNET_PQ_make_prepare ("store_records", | 150 | GNUNET_PQ_make_prepare ("store_records", |
151 | "INSERT INTO ns097records (zone_private_key, pkey, rvalue, record_count, record_data, label) VALUES " | 151 | "INSERT INTO ns098records (zone_private_key, pkey, rvalue, record_count, record_data, label) VALUES " |
152 | "($1, $2, $3, $4, $5, $6)", | 152 | "($1, $2, $3, $4, $5, $6)", |
153 | 6), | 153 | 6), |
154 | GNUNET_PQ_make_prepare ("delete_records", | 154 | GNUNET_PQ_make_prepare ("delete_records", |
155 | "DELETE FROM ns097records " | 155 | "DELETE FROM ns098records " |
156 | "WHERE zone_private_key=$1 AND label=$2", | 156 | "WHERE zone_private_key=$1 AND label=$2", |
157 | 2), | 157 | 2), |
158 | GNUNET_PQ_make_prepare ("zone_to_name", | 158 | GNUNET_PQ_make_prepare ("zone_to_name", |
159 | "SELECT record_count,record_data,label FROM ns097records" | 159 | "SELECT seq,record_count,record_data,label FROM ns098records" |
160 | " WHERE zone_private_key=$1 AND pkey=$2", | 160 | " WHERE zone_private_key=$1 AND pkey=$2", |
161 | 2), | 161 | 2), |
162 | GNUNET_PQ_make_prepare ("iterate_zone", | 162 | GNUNET_PQ_make_prepare ("iterate_zone", |
163 | "SELECT record_count,record_data,label FROM ns097records " | 163 | "SELECT seq,record_count,record_data,label FROM ns098records " |
164 | "WHERE zone_private_key=$1 ORDER BY rvalue OFFSET $2 LIMIT $3", | 164 | "WHERE zone_private_key=$1 AND seq > $2 ORDER BY seq ASC LIMIT $3", |
165 | 3), | 165 | 3), |
166 | GNUNET_PQ_make_prepare ("iterate_all_zones", | 166 | GNUNET_PQ_make_prepare ("iterate_all_zones", |
167 | "SELECT record_count,record_data,label,zone_private_key" | 167 | "SELECT seq,record_count,record_data,label,zone_private_key" |
168 | " FROM ns097records ORDER BY rvalue OFFSET $1 LIMIT $2", | 168 | " FROM ns098records WHERE seq > $1 ORDER BY seq ASC LIMIT $2", |
169 | 2), | 169 | 2), |
170 | GNUNET_PQ_make_prepare ("lookup_label", | 170 | GNUNET_PQ_make_prepare ("lookup_label", |
171 | "SELECT record_count,record_data,label " | 171 | "SELECT seq,record_count,record_data,label " |
172 | "FROM ns097records WHERE zone_private_key=$1 AND label=$2", | 172 | "FROM ns098records WHERE zone_private_key=$1 AND label=$2", |
173 | 2), | 173 | 2), |
174 | GNUNET_PQ_PREPARED_STATEMENT_END | 174 | GNUNET_PQ_PREPARED_STATEMENT_END |
175 | }; | 175 | }; |
@@ -224,7 +224,8 @@ namestore_postgres_store_records (void *cls, | |||
224 | } | 224 | } |
225 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 225 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
226 | UINT64_MAX); | 226 | UINT64_MAX); |
227 | data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd); | 227 | data_size = GNUNET_GNSRECORD_records_get_size (rd_count, |
228 | rd); | ||
228 | if (data_size > 64 * 65536) | 229 | if (data_size > 64 * 65536) |
229 | { | 230 | { |
230 | GNUNET_break (0); | 231 | GNUNET_break (0); |
@@ -312,12 +313,14 @@ parse_result_call_iterator (void *cls, | |||
312 | return; /* no need to do more work */ | 313 | return; /* no need to do more work */ |
313 | for (unsigned int i=0;i<num_results;i++) | 314 | for (unsigned int i=0;i<num_results;i++) |
314 | { | 315 | { |
316 | uint64_t serial; | ||
315 | void *data; | 317 | void *data; |
316 | size_t data_size; | 318 | size_t data_size; |
317 | uint32_t record_count; | 319 | uint32_t record_count; |
318 | char *label; | 320 | char *label; |
319 | struct GNUNET_CRYPTO_EcdsaPrivateKey zk; | 321 | struct GNUNET_CRYPTO_EcdsaPrivateKey zk; |
320 | struct GNUNET_PQ_ResultSpec rs_with_zone[] = { | 322 | struct GNUNET_PQ_ResultSpec rs_with_zone[] = { |
323 | GNUNET_PQ_result_spec_uint64 ("seq", &serial), | ||
321 | GNUNET_PQ_result_spec_uint32 ("record_count", &record_count), | 324 | GNUNET_PQ_result_spec_uint32 ("record_count", &record_count), |
322 | GNUNET_PQ_result_spec_variable_size ("record_data", &data, &data_size), | 325 | GNUNET_PQ_result_spec_variable_size ("record_data", &data, &data_size), |
323 | GNUNET_PQ_result_spec_string ("label", &label), | 326 | GNUNET_PQ_result_spec_string ("label", &label), |
@@ -325,6 +328,7 @@ parse_result_call_iterator (void *cls, | |||
325 | GNUNET_PQ_result_spec_end | 328 | GNUNET_PQ_result_spec_end |
326 | }; | 329 | }; |
327 | struct GNUNET_PQ_ResultSpec rs_without_zone[] = { | 330 | struct GNUNET_PQ_ResultSpec rs_without_zone[] = { |
331 | GNUNET_PQ_result_spec_uint64 ("seq", &serial), | ||
328 | GNUNET_PQ_result_spec_uint32 ("record_count", &record_count), | 332 | GNUNET_PQ_result_spec_uint32 ("record_count", &record_count), |
329 | GNUNET_PQ_result_spec_variable_size ("record_data", &data, &data_size), | 333 | GNUNET_PQ_result_spec_variable_size ("record_data", &data, &data_size), |
330 | GNUNET_PQ_result_spec_string ("label", &label), | 334 | GNUNET_PQ_result_spec_string ("label", &label), |
@@ -365,6 +369,7 @@ parse_result_call_iterator (void *cls, | |||
365 | return; | 369 | return; |
366 | } | 370 | } |
367 | pc->iter (pc->iter_cls, | 371 | pc->iter (pc->iter_cls, |
372 | serial, | ||
368 | (NULL == pc->zone_key) ? &zk : pc->zone_key, | 373 | (NULL == pc->zone_key) ? &zk : pc->zone_key, |
369 | label, | 374 | label, |
370 | record_count, | 375 | record_count, |
@@ -422,7 +427,7 @@ namestore_postgres_lookup_records (void *cls, | |||
422 | * | 427 | * |
423 | * @param cls closure (internal context for the plugin) | 428 | * @param cls closure (internal context for the plugin) |
424 | * @param zone hash of public key of the zone, NULL to iterate over all zones | 429 | * @param zone hash of public key of the zone, NULL to iterate over all zones |
425 | * @param offset offset in the list of all matching records | 430 | * @param serial serial number to exclude in the list of all matching records |
426 | * @param limit maximum number of results to fetch | 431 | * @param limit maximum number of results to fetch |
427 | * @param iter function to call with the result | 432 | * @param iter function to call with the result |
428 | * @param iter_cls closure for @a iter | 433 | * @param iter_cls closure for @a iter |
@@ -431,7 +436,7 @@ namestore_postgres_lookup_records (void *cls, | |||
431 | static int | 436 | static int |
432 | namestore_postgres_iterate_records (void *cls, | 437 | namestore_postgres_iterate_records (void *cls, |
433 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 438 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
434 | uint64_t offset, | 439 | uint64_t serial, |
435 | uint64_t limit, | 440 | uint64_t limit, |
436 | GNUNET_NAMESTORE_RecordIterator iter, | 441 | GNUNET_NAMESTORE_RecordIterator iter, |
437 | void *iter_cls) | 442 | void *iter_cls) |
@@ -447,7 +452,7 @@ namestore_postgres_iterate_records (void *cls, | |||
447 | if (NULL == zone) | 452 | if (NULL == zone) |
448 | { | 453 | { |
449 | struct GNUNET_PQ_QueryParam params_without_zone[] = { | 454 | struct GNUNET_PQ_QueryParam params_without_zone[] = { |
450 | GNUNET_PQ_query_param_uint64 (&offset), | 455 | GNUNET_PQ_query_param_uint64 (&serial), |
451 | GNUNET_PQ_query_param_uint64 (&limit), | 456 | GNUNET_PQ_query_param_uint64 (&limit), |
452 | GNUNET_PQ_query_param_end | 457 | GNUNET_PQ_query_param_end |
453 | }; | 458 | }; |
@@ -462,7 +467,7 @@ namestore_postgres_iterate_records (void *cls, | |||
462 | { | 467 | { |
463 | struct GNUNET_PQ_QueryParam params_with_zone[] = { | 468 | struct GNUNET_PQ_QueryParam params_with_zone[] = { |
464 | GNUNET_PQ_query_param_auto_from_type (zone), | 469 | GNUNET_PQ_query_param_auto_from_type (zone), |
465 | GNUNET_PQ_query_param_uint64 (&offset), | 470 | GNUNET_PQ_query_param_uint64 (&serial), |
466 | GNUNET_PQ_query_param_uint64 (&limit), | 471 | GNUNET_PQ_query_param_uint64 (&limit), |
467 | GNUNET_PQ_query_param_end | 472 | GNUNET_PQ_query_param_end |
468 | }; | 473 | }; |
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c index f905787b5..b54b4dba2 100644 --- a/src/namestore/plugin_namestore_sqlite.c +++ b/src/namestore/plugin_namestore_sqlite.c | |||
@@ -147,15 +147,13 @@ create_indices (sqlite3 * dbh) | |||
147 | /* create indices */ | 147 | /* create indices */ |
148 | if ( (SQLITE_OK != | 148 | if ( (SQLITE_OK != |
149 | sqlite3_exec (dbh, | 149 | sqlite3_exec (dbh, |
150 | "CREATE INDEX IF NOT EXISTS ir_pkey_reverse ON ns097records (zone_private_key,pkey)", | 150 | "CREATE INDEX IF NOT EXISTS ir_pkey_reverse " |
151 | "ON ns098records (zone_private_key,pkey)", | ||
151 | NULL, NULL, NULL)) || | 152 | NULL, NULL, NULL)) || |
152 | (SQLITE_OK != | 153 | (SQLITE_OK != |
153 | sqlite3_exec (dbh, | 154 | sqlite3_exec (dbh, |
154 | "CREATE INDEX IF NOT EXISTS ir_pkey_iter ON ns097records (zone_private_key,rvalue)", | 155 | "CREATE INDEX IF NOT EXISTS ir_pkey_iter " |
155 | NULL, NULL, NULL)) || | 156 | "ON ns098records (zone_private_key,uid)", |
156 | (SQLITE_OK != | ||
157 | sqlite3_exec (dbh, | ||
158 | "CREATE INDEX IF NOT EXISTS it_iter ON ns097records (rvalue)", | ||
159 | NULL, NULL, NULL)) ) | 157 | NULL, NULL, NULL)) ) |
160 | LOG (GNUNET_ERROR_TYPE_ERROR, | 158 | LOG (GNUNET_ERROR_TYPE_ERROR, |
161 | "Failed to create indices: %s\n", | 159 | "Failed to create indices: %s\n", |
@@ -260,22 +258,24 @@ database_setup (struct Plugin *plugin) | |||
260 | /* Create table */ | 258 | /* Create table */ |
261 | CHECK (SQLITE_OK == | 259 | CHECK (SQLITE_OK == |
262 | sq_prepare (plugin->dbh, | 260 | sq_prepare (plugin->dbh, |
263 | "SELECT 1 FROM sqlite_master WHERE tbl_name = 'ns097records'", | 261 | "SELECT 1 FROM sqlite_master WHERE tbl_name = 'ns098records'", |
264 | &stmt)); | 262 | &stmt)); |
265 | if ((sqlite3_step (stmt) == SQLITE_DONE) && | 263 | if ( (sqlite3_step (stmt) == SQLITE_DONE) && |
266 | (sqlite3_exec | 264 | (SQLITE_OK != |
267 | (plugin->dbh, | 265 | sqlite3_exec (plugin->dbh, |
268 | "CREATE TABLE ns097records (" | 266 | "CREATE TABLE ns098records (" |
269 | " zone_private_key BLOB NOT NULL," | 267 | " uid INTEGER PRIMARY KEY," |
270 | " pkey BLOB," | 268 | " zone_private_key BLOB NOT NULL," |
271 | " rvalue INT8 NOT NULL," | 269 | " pkey BLOB," |
272 | " record_count INT NOT NULL," | 270 | " rvalue INT8 NOT NULL," |
273 | " record_data BLOB NOT NULL," | 271 | " record_count INT NOT NULL," |
274 | " label TEXT NOT NULL" | 272 | " record_data BLOB NOT NULL," |
275 | ")", | 273 | " label TEXT NOT NULL" |
276 | NULL, NULL, NULL) != SQLITE_OK)) | 274 | ")", |
275 | NULL, NULL, NULL)) ) | ||
277 | { | 276 | { |
278 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, | 277 | LOG_SQLITE (plugin, |
278 | GNUNET_ERROR_TYPE_ERROR, | ||
279 | "sqlite3_exec"); | 279 | "sqlite3_exec"); |
280 | sqlite3_finalize (stmt); | 280 | sqlite3_finalize (stmt); |
281 | return GNUNET_SYSERR; | 281 | return GNUNET_SYSERR; |
@@ -286,33 +286,40 @@ database_setup (struct Plugin *plugin) | |||
286 | 286 | ||
287 | if ( (SQLITE_OK != | 287 | if ( (SQLITE_OK != |
288 | sq_prepare (plugin->dbh, | 288 | sq_prepare (plugin->dbh, |
289 | "INSERT INTO ns097records (zone_private_key, pkey, rvalue, record_count, record_data, label)" | 289 | "INSERT INTO ns098records (zone_private_key, pkey, rvalue, record_count, record_data, label)" |
290 | " VALUES (?, ?, ?, ?, ?, ?)", | 290 | " VALUES (?, ?, ?, ?, ?, ?)", |
291 | &plugin->store_records)) || | 291 | &plugin->store_records)) || |
292 | (SQLITE_OK != | 292 | (SQLITE_OK != |
293 | sq_prepare (plugin->dbh, | 293 | sq_prepare (plugin->dbh, |
294 | "DELETE FROM ns097records WHERE zone_private_key=? AND label=?", | 294 | "DELETE FROM ns098records WHERE zone_private_key=? AND label=?", |
295 | &plugin->delete_records)) || | 295 | &plugin->delete_records)) || |
296 | (SQLITE_OK != | 296 | (SQLITE_OK != |
297 | sq_prepare (plugin->dbh, | 297 | sq_prepare (plugin->dbh, |
298 | "SELECT record_count,record_data,label" | 298 | "SELECT uid,record_count,record_data,label" |
299 | " FROM ns097records WHERE zone_private_key=? AND pkey=?", | 299 | " FROM ns098records" |
300 | " WHERE zone_private_key=? AND pkey=?", | ||
300 | &plugin->zone_to_name)) || | 301 | &plugin->zone_to_name)) || |
301 | (SQLITE_OK != | 302 | (SQLITE_OK != |
302 | sq_prepare (plugin->dbh, | 303 | sq_prepare (plugin->dbh, |
303 | "SELECT record_count,record_data,label" | 304 | "SELECT uid,record_count,record_data,label" |
304 | " FROM ns097records WHERE zone_private_key=?" | 305 | " FROM ns098records" |
305 | " ORDER BY rvalue LIMIT ? OFFSET ?", | 306 | " WHERE zone_private_key=? AND _rowid_ >= ?" |
307 | " ORDER BY _rowid_ ASC" | ||
308 | " LIMIT ?", | ||
306 | &plugin->iterate_zone)) || | 309 | &plugin->iterate_zone)) || |
307 | (SQLITE_OK != | 310 | (SQLITE_OK != |
308 | sq_prepare (plugin->dbh, | 311 | sq_prepare (plugin->dbh, |
309 | "SELECT record_count,record_data,label,zone_private_key" | 312 | "SELECT uid,record_count,record_data,label,zone_private_key" |
310 | " FROM ns097records ORDER BY rvalue LIMIT ? OFFSET ?", | 313 | " FROM ns098records" |
314 | " WHERE _rowid_ >= ?" | ||
315 | " ORDER BY _rowid_ ASC" | ||
316 | " LIMIT ?", | ||
311 | &plugin->iterate_all_zones)) || | 317 | &plugin->iterate_all_zones)) || |
312 | (SQLITE_OK != | 318 | (SQLITE_OK != |
313 | sq_prepare (plugin->dbh, | 319 | sq_prepare (plugin->dbh, |
314 | "SELECT record_count,record_data,label,zone_private_key" | 320 | "SELECT uid,record_count,record_data,label,zone_private_key" |
315 | " FROM ns097records WHERE zone_private_key=? AND label=?", | 321 | " FROM ns098records" |
322 | " WHERE zone_private_key=? AND label=?", | ||
316 | &plugin->lookup_label)) | 323 | &plugin->lookup_label)) |
317 | ) | 324 | ) |
318 | { | 325 | { |
@@ -405,10 +412,11 @@ namestore_sqlite_store_records (void *cls, | |||
405 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; | 412 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; |
406 | uint64_t rvalue; | 413 | uint64_t rvalue; |
407 | size_t data_size; | 414 | size_t data_size; |
408 | unsigned int i; | ||
409 | 415 | ||
410 | memset (&pkey, 0, sizeof (pkey)); | 416 | memset (&pkey, |
411 | for (i=0;i<rd_count;i++) | 417 | 0, |
418 | sizeof (pkey)); | ||
419 | for (unsigned int i=0;i<rd_count;i++) | ||
412 | if (GNUNET_GNSRECORD_TYPE_PKEY == rd[i].record_type) | 420 | if (GNUNET_GNSRECORD_TYPE_PKEY == rd[i].record_type) |
413 | { | 421 | { |
414 | GNUNET_break (sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) == | 422 | GNUNET_break (sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) == |
@@ -539,28 +547,50 @@ get_records_and_call_iterator (struct Plugin *plugin, | |||
539 | GNUNET_NAMESTORE_RecordIterator iter, | 547 | GNUNET_NAMESTORE_RecordIterator iter, |
540 | void *iter_cls) | 548 | void *iter_cls) |
541 | { | 549 | { |
542 | uint32_t record_count; | ||
543 | size_t data_size; | ||
544 | void *data; | ||
545 | char *label; | ||
546 | struct GNUNET_CRYPTO_EcdsaPrivateKey zk; | ||
547 | int ret; | 550 | int ret; |
548 | int sret; | 551 | int sret; |
549 | 552 | ||
550 | ret = GNUNET_OK; | 553 | ret = GNUNET_OK; |
551 | for (uint64_t i = 0;i<limit ; i++) | 554 | for (uint64_t i = 0;i<limit ; i++) |
552 | { | 555 | { |
553 | if (SQLITE_ROW == (sret = sqlite3_step (stmt))) | 556 | sret = sqlite3_step (stmt); |
557 | |||
558 | if (SQLITE_DONE == sret) | ||
559 | { | ||
560 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
561 | "Iteration done (no results)\n"); | ||
562 | ret = GNUNET_NO; | ||
563 | break; | ||
564 | } | ||
565 | if (SQLITE_ROW != sret) | ||
554 | { | 566 | { |
567 | LOG_SQLITE (plugin, | ||
568 | GNUNET_ERROR_TYPE_ERROR, | ||
569 | "sqlite_step"); | ||
570 | ret = GNUNET_SYSERR; | ||
571 | break; | ||
572 | } | ||
573 | |||
574 | { | ||
575 | uint64_t seq; | ||
576 | uint32_t record_count; | ||
577 | size_t data_size; | ||
578 | void *data; | ||
579 | char *label; | ||
580 | struct GNUNET_CRYPTO_EcdsaPrivateKey zk; | ||
555 | struct GNUNET_SQ_ResultSpec rs[] = { | 581 | struct GNUNET_SQ_ResultSpec rs[] = { |
582 | GNUNET_SQ_result_spec_uint64 (&seq), | ||
556 | GNUNET_SQ_result_spec_uint32 (&record_count), | 583 | GNUNET_SQ_result_spec_uint32 (&record_count), |
557 | GNUNET_SQ_result_spec_variable_size (&data, &data_size), | 584 | GNUNET_SQ_result_spec_variable_size (&data, |
585 | &data_size), | ||
558 | GNUNET_SQ_result_spec_string (&label), | 586 | GNUNET_SQ_result_spec_string (&label), |
559 | GNUNET_SQ_result_spec_end | 587 | GNUNET_SQ_result_spec_end |
560 | }; | 588 | }; |
561 | struct GNUNET_SQ_ResultSpec rsx[] = { | 589 | struct GNUNET_SQ_ResultSpec rsx[] = { |
590 | GNUNET_SQ_result_spec_uint64 (&seq), | ||
562 | GNUNET_SQ_result_spec_uint32 (&record_count), | 591 | GNUNET_SQ_result_spec_uint32 (&record_count), |
563 | GNUNET_SQ_result_spec_variable_size (&data, &data_size), | 592 | GNUNET_SQ_result_spec_variable_size (&data, |
593 | &data_size), | ||
564 | GNUNET_SQ_result_spec_string (&label), | 594 | GNUNET_SQ_result_spec_string (&label), |
565 | GNUNET_SQ_result_spec_auto_from_type (&zk), | 595 | GNUNET_SQ_result_spec_auto_from_type (&zk), |
566 | GNUNET_SQ_result_spec_end | 596 | GNUNET_SQ_result_spec_end |
@@ -604,6 +634,7 @@ get_records_and_call_iterator (struct Plugin *plugin, | |||
604 | { | 634 | { |
605 | if (NULL != iter) | 635 | if (NULL != iter) |
606 | iter (iter_cls, | 636 | iter (iter_cls, |
637 | seq + 1, | ||
607 | zone_key, | 638 | zone_key, |
608 | label, | 639 | label, |
609 | record_count, | 640 | record_count, |
@@ -612,21 +643,6 @@ get_records_and_call_iterator (struct Plugin *plugin, | |||
612 | } | 643 | } |
613 | GNUNET_SQ_cleanup_result (rs); | 644 | GNUNET_SQ_cleanup_result (rs); |
614 | } | 645 | } |
615 | else | ||
616 | { | ||
617 | if (SQLITE_DONE != sret) | ||
618 | { | ||
619 | LOG_SQLITE (plugin, | ||
620 | GNUNET_ERROR_TYPE_ERROR, | ||
621 | "sqlite_step"); | ||
622 | ret = GNUNET_SYSERR; | ||
623 | } | ||
624 | else | ||
625 | { | ||
626 | ret = GNUNET_NO; | ||
627 | } | ||
628 | break; | ||
629 | } | ||
630 | } | 646 | } |
631 | GNUNET_SQ_reset (plugin->dbh, | 647 | GNUNET_SQ_reset (plugin->dbh, |
632 | stmt); | 648 | stmt); |
@@ -685,7 +701,7 @@ namestore_sqlite_lookup_records (void *cls, | |||
685 | * | 701 | * |
686 | * @param cls closure (internal context for the plugin) | 702 | * @param cls closure (internal context for the plugin) |
687 | * @param zone hash of public key of the zone, NULL to iterate over all zones | 703 | * @param zone hash of public key of the zone, NULL to iterate over all zones |
688 | * @param offset offset in the list of all matching records | 704 | * @param serial serial number to exclude in the list of all matching records |
689 | * @param limit maximum number of results to return | 705 | * @param limit maximum number of results to return |
690 | * @param iter function to call with the result | 706 | * @param iter function to call with the result |
691 | * @param iter_cls closure for @a iter | 707 | * @param iter_cls closure for @a iter |
@@ -694,7 +710,7 @@ namestore_sqlite_lookup_records (void *cls, | |||
694 | static int | 710 | static int |
695 | namestore_sqlite_iterate_records (void *cls, | 711 | namestore_sqlite_iterate_records (void *cls, |
696 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 712 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
697 | uint64_t offset, | 713 | uint64_t serial, |
698 | uint64_t limit, | 714 | uint64_t limit, |
699 | GNUNET_NAMESTORE_RecordIterator iter, | 715 | GNUNET_NAMESTORE_RecordIterator iter, |
700 | void *iter_cls) | 716 | void *iter_cls) |
@@ -706,8 +722,8 @@ namestore_sqlite_iterate_records (void *cls, | |||
706 | if (NULL == zone) | 722 | if (NULL == zone) |
707 | { | 723 | { |
708 | struct GNUNET_SQ_QueryParam params[] = { | 724 | struct GNUNET_SQ_QueryParam params[] = { |
725 | GNUNET_SQ_query_param_uint64 (&serial), | ||
709 | GNUNET_SQ_query_param_uint64 (&limit), | 726 | GNUNET_SQ_query_param_uint64 (&limit), |
710 | GNUNET_SQ_query_param_uint64 (&offset), | ||
711 | GNUNET_SQ_query_param_end | 727 | GNUNET_SQ_query_param_end |
712 | }; | 728 | }; |
713 | 729 | ||
@@ -719,8 +735,8 @@ namestore_sqlite_iterate_records (void *cls, | |||
719 | { | 735 | { |
720 | struct GNUNET_SQ_QueryParam params[] = { | 736 | struct GNUNET_SQ_QueryParam params[] = { |
721 | GNUNET_SQ_query_param_auto_from_type (zone), | 737 | GNUNET_SQ_query_param_auto_from_type (zone), |
738 | GNUNET_SQ_query_param_uint64 (&serial), | ||
722 | GNUNET_SQ_query_param_uint64 (&limit), | 739 | GNUNET_SQ_query_param_uint64 (&limit), |
723 | GNUNET_SQ_query_param_uint64 (&offset), | ||
724 | GNUNET_SQ_query_param_end | 740 | GNUNET_SQ_query_param_end |
725 | }; | 741 | }; |
726 | 742 | ||
@@ -761,7 +777,8 @@ static int | |||
761 | namestore_sqlite_zone_to_name (void *cls, | 777 | namestore_sqlite_zone_to_name (void *cls, |
762 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 778 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
763 | const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, | 779 | const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, |
764 | GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) | 780 | GNUNET_NAMESTORE_RecordIterator iter, |
781 | void *iter_cls) | ||
765 | { | 782 | { |
766 | struct Plugin *plugin = cls; | 783 | struct Plugin *plugin = cls; |
767 | struct GNUNET_SQ_QueryParam params[] = { | 784 | struct GNUNET_SQ_QueryParam params[] = { |
diff --git a/src/namestore/test_namestore_api_monitoring.c b/src/namestore/test_namestore_api_monitoring.c index efbd6badf..68a3e4fb8 100644 --- a/src/namestore/test_namestore_api_monitoring.c +++ b/src/namestore/test_namestore_api_monitoring.c | |||
@@ -209,7 +209,9 @@ zone_proc (void *cls, | |||
209 | 209 | ||
210 | 210 | ||
211 | static void | 211 | static void |
212 | put_cont (void *cls, int32_t success, const char *emsg) | 212 | put_cont (void *cls, |
213 | int32_t success, | ||
214 | const char *emsg) | ||
213 | { | 215 | { |
214 | static int c = 0; | 216 | static int c = 0; |
215 | char *label = cls; | 217 | char *label = cls; |
@@ -232,10 +234,12 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
232 | else | 234 | else |
233 | { | 235 | { |
234 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 236 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
235 | "Failed to created records\n"); | 237 | "Failed to create record `%s'\n", |
238 | label); | ||
236 | GNUNET_break (0); | 239 | GNUNET_break (0); |
237 | GNUNET_SCHEDULER_cancel (endbadly_task); | 240 | GNUNET_SCHEDULER_cancel (endbadly_task); |
238 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 241 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, |
242 | NULL); | ||
239 | } | 243 | } |
240 | } | 244 | } |
241 | 245 | ||
@@ -341,10 +345,16 @@ run (void *cls, | |||
341 | /* name in different zone */ | 345 | /* name in different zone */ |
342 | GNUNET_asprintf(&s_name_3, "dummy3"); | 346 | GNUNET_asprintf(&s_name_3, "dummy3"); |
343 | s_rd_3 = create_record(1); | 347 | s_rd_3 = create_record(1); |
344 | GNUNET_assert (NULL != (ns_ops[2] = GNUNET_NAMESTORE_records_store (nsh, privkey2, s_name_3, | 348 | GNUNET_assert (NULL != (ns_ops[2] = |
345 | 1, s_rd_3, &put_cont, s_name_3))); | 349 | GNUNET_NAMESTORE_records_store (nsh, |
346 | 350 | privkey2, | |
347 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); | 351 | s_name_3, |
352 | 1, | ||
353 | s_rd_3, | ||
354 | &put_cont, | ||
355 | s_name_3))); | ||
356 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
357 | "Created record 1\n"); | ||
348 | GNUNET_asprintf(&s_name_1, "dummy1"); | 358 | GNUNET_asprintf(&s_name_1, "dummy1"); |
349 | s_rd_1 = create_record(1); | 359 | s_rd_1 = create_record(1); |
350 | GNUNET_assert (NULL != (ns_ops[0] = GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, | 360 | GNUNET_assert (NULL != (ns_ops[0] = GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, |
diff --git a/src/namestore/test_plugin_namestore.c b/src/namestore/test_plugin_namestore.c index d591eb325..ac2a0bba9 100644 --- a/src/namestore/test_plugin_namestore.c +++ b/src/namestore/test_plugin_namestore.c | |||
@@ -90,6 +90,7 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
90 | 90 | ||
91 | static void | 91 | static void |
92 | test_record (void *cls, | 92 | test_record (void *cls, |
93 | uint64_t seq, | ||
93 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, | 94 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, |
94 | const char *label, | 95 | const char *label, |
95 | unsigned int rd_count, | 96 | unsigned int rd_count, |
@@ -112,7 +113,9 @@ test_record (void *cls, | |||
112 | GNUNET_assert (rd[i].record_type == 1 + (id % 13)); | 113 | GNUNET_assert (rd[i].record_type == 1 + (id % 13)); |
113 | GNUNET_assert (rd[i].flags == 0); | 114 | GNUNET_assert (rd[i].flags == 0); |
114 | } | 115 | } |
115 | memset (&tzone_private_key, (id % 241), sizeof (tzone_private_key)); | 116 | memset (&tzone_private_key, |
117 | (id % 241), | ||
118 | sizeof (tzone_private_key)); | ||
116 | GNUNET_assert (0 == strcmp (label, tname)); | 119 | GNUNET_assert (0 == strcmp (label, tname)); |
117 | GNUNET_assert (0 == memcmp (&tzone_private_key, | 120 | GNUNET_assert (0 == memcmp (&tzone_private_key, |
118 | private_key, | 121 | private_key, |
@@ -156,11 +159,12 @@ put_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, | |||
156 | } | 159 | } |
157 | memset (&zone_private_key, (id % 241), sizeof (zone_private_key)); | 160 | memset (&zone_private_key, (id % 241), sizeof (zone_private_key)); |
158 | memset (&signature, (id % 243), sizeof (signature)); | 161 | memset (&signature, (id % 243), sizeof (signature)); |
159 | GNUNET_assert (GNUNET_OK == nsp->store_records (nsp->cls, | 162 | GNUNET_assert (GNUNET_OK == |
160 | &zone_private_key, | 163 | nsp->store_records (nsp->cls, |
161 | label, | 164 | &zone_private_key, |
162 | rd_count, | 165 | label, |
163 | rd)); | 166 | rd_count, |
167 | rd)); | ||
164 | } | 168 | } |
165 | 169 | ||
166 | 170 | ||