aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/gnunet-service-namestore.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-04-30 16:22:47 +0200
committerChristian Grothoff <christian@grothoff.org>2018-04-30 16:22:47 +0200
commit4b5c6cceb0284774a161d426b606f40644abfb4c (patch)
treef2f63b8df7e6bb329ef25eca97e27d4deac55b69 /src/namestore/gnunet-service-namestore.c
parentc66809401efc16f2606db7e2c7b7ca8def8be14e (diff)
downloadgnunet-4b5c6cceb0284774a161d426b606f40644abfb4c.tar.gz
gnunet-4b5c6cceb0284774a161d426b606f40644abfb4c.zip
eliminate use of OFFSET in namestore DB queries
Diffstat (limited to 'src/namestore/gnunet-service-namestore.c')
-rw-r--r--src/namestore/gnunet-service-namestore.c43
1 files changed, 33 insertions, 10 deletions
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 */
402static void 412static void
403lookup_nick_it (void *cls, 413lookup_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 */
817static void 830static void
818lookup_it (void *cls, 831lookup_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 */
1220static void 1236static void
1221handle_zone_to_name_it (void *cls, 1237handle_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 */
1352static void 1371static void
1353zone_iterate_proc (void *cls, 1372zone_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 */
1605static void 1626static void
1606monitor_iterate_cb (void *cls, 1627monitor_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);