diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2018-10-15 18:41:29 +0900 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2018-10-15 18:41:29 +0900 |
commit | 03fb70c9384b208cbeb57fb6c9b06145aa9c2e9e (patch) | |
tree | 4bbf347dd239440874beb2720d17c0312adf2990 | |
parent | 4cefd61da32ee7adf3cfc4167217bfcbb1e6d2e3 (diff) | |
download | gnunet-03fb70c9384b208cbeb57fb6c9b06145aa9c2e9e.tar.gz gnunet-03fb70c9384b208cbeb57fb6c9b06145aa9c2e9e.zip |
modify sqlite logic to accomodate rowcount starting from 1
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 20 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_sqlite.c | 15 |
2 files changed, 18 insertions, 17 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index cdefd0be9..6ad7354ad 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -713,9 +713,8 @@ send_store_response (struct NamestoreClient *nc, | |||
713 | { | 713 | { |
714 | struct GNUNET_MQ_Envelope *env; | 714 | struct GNUNET_MQ_Envelope *env; |
715 | struct RecordStoreResponseMessage *rcr_msg; | 715 | struct RecordStoreResponseMessage *rcr_msg; |
716 | 716 | ||
717 | if (NULL == nc) | 717 | GNUNET_assert (NULL != nc); |
718 | return; | ||
719 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 718 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
720 | "Sending RECORD_STORE_RESPONSE message\n"); | 719 | "Sending RECORD_STORE_RESPONSE message\n"); |
721 | GNUNET_STATISTICS_update (statistics, | 720 | GNUNET_STATISTICS_update (statistics, |
@@ -804,9 +803,10 @@ refresh_block (struct NamestoreClient *nc, | |||
804 | } | 803 | } |
805 | if (0 == res_count) | 804 | if (0 == res_count) |
806 | { | 805 | { |
807 | send_store_response (nc, | 806 | if (NULL != nc) |
808 | GNUNET_OK, | 807 | send_store_response (nc, |
809 | rid); | 808 | GNUNET_OK, |
809 | rid); | ||
810 | return; /* no data, no need to update cache */ | 810 | return; /* no data, no need to update cache */ |
811 | } | 811 | } |
812 | if (GNUNET_YES == disable_namecache) | 812 | if (GNUNET_YES == disable_namecache) |
@@ -815,9 +815,10 @@ refresh_block (struct NamestoreClient *nc, | |||
815 | "Namecache updates skipped (NC disabled)", | 815 | "Namecache updates skipped (NC disabled)", |
816 | 1, | 816 | 1, |
817 | GNUNET_NO); | 817 | GNUNET_NO); |
818 | send_store_response (nc, | 818 | if (NULL != nc) |
819 | GNUNET_OK, | 819 | send_store_response (nc, |
820 | rid); | 820 | GNUNET_OK, |
821 | rid); | ||
821 | return; | 822 | return; |
822 | } | 823 | } |
823 | exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, | 824 | exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, |
@@ -1808,7 +1809,6 @@ handle_iteration_start (void *cls, | |||
1808 | zi->request_id = ntohl (zis_msg->gns_header.r_id); | 1809 | zi->request_id = ntohl (zis_msg->gns_header.r_id); |
1809 | zi->offset = 0; | 1810 | zi->offset = 0; |
1810 | zi->nc = nc; | 1811 | zi->nc = nc; |
1811 | zi->seq = 1; | ||
1812 | zi->zone = zis_msg->zone; | 1812 | zi->zone = zis_msg->zone; |
1813 | 1813 | ||
1814 | GNUNET_CONTAINER_DLL_insert (nc->op_head, | 1814 | GNUNET_CONTAINER_DLL_insert (nc->op_head, |
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c index 07784a779..1a4e0138c 100644 --- a/src/namestore/plugin_namestore_sqlite.c +++ b/src/namestore/plugin_namestore_sqlite.c | |||
@@ -152,14 +152,14 @@ database_setup (struct Plugin *plugin) | |||
152 | &plugin->zone_to_name), | 152 | &plugin->zone_to_name), |
153 | GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label" | 153 | GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label" |
154 | " FROM ns098records" | 154 | " FROM ns098records" |
155 | " WHERE zone_private_key=? AND _rowid_ >= ?" | 155 | " WHERE zone_private_key=? AND uid >= ?" |
156 | " ORDER BY _rowid_ ASC" | 156 | " ORDER BY uid ASC" |
157 | " LIMIT ?", | 157 | " LIMIT ?", |
158 | &plugin->iterate_zone), | 158 | &plugin->iterate_zone), |
159 | GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label,zone_private_key" | 159 | GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label,zone_private_key" |
160 | " FROM ns098records" | 160 | " FROM ns098records" |
161 | " WHERE _rowid_ >= ?" | 161 | " WHERE uid >= ?" |
162 | " ORDER BY _rowid_ ASC" | 162 | " ORDER BY uid ASC" |
163 | " LIMIT ?", | 163 | " LIMIT ?", |
164 | &plugin->iterate_all_zones), | 164 | &plugin->iterate_all_zones), |
165 | GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label,zone_private_key" | 165 | GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label,zone_private_key" |
@@ -540,7 +540,7 @@ get_records_and_call_iterator (struct Plugin *plugin, | |||
540 | zk = *zone_key; | 540 | zk = *zone_key; |
541 | if (NULL != iter) | 541 | if (NULL != iter) |
542 | iter (iter_cls, | 542 | iter (iter_cls, |
543 | seq + 1, | 543 | seq, |
544 | &zk, | 544 | &zk, |
545 | label, | 545 | label, |
546 | record_count, | 546 | record_count, |
@@ -627,11 +627,12 @@ namestore_sqlite_iterate_records (void *cls, | |||
627 | struct Plugin *plugin = cls; | 627 | struct Plugin *plugin = cls; |
628 | sqlite3_stmt *stmt; | 628 | sqlite3_stmt *stmt; |
629 | int err; | 629 | int err; |
630 | uint64_t rowid = serial + 1; //SQLite starts counting at 1 | ||
630 | 631 | ||
631 | if (NULL == zone) | 632 | if (NULL == zone) |
632 | { | 633 | { |
633 | struct GNUNET_SQ_QueryParam params[] = { | 634 | struct GNUNET_SQ_QueryParam params[] = { |
634 | GNUNET_SQ_query_param_uint64 (&serial), | 635 | GNUNET_SQ_query_param_uint64 (&rowid), |
635 | GNUNET_SQ_query_param_uint64 (&limit), | 636 | GNUNET_SQ_query_param_uint64 (&limit), |
636 | GNUNET_SQ_query_param_end | 637 | GNUNET_SQ_query_param_end |
637 | }; | 638 | }; |
@@ -644,7 +645,7 @@ namestore_sqlite_iterate_records (void *cls, | |||
644 | { | 645 | { |
645 | struct GNUNET_SQ_QueryParam params[] = { | 646 | struct GNUNET_SQ_QueryParam params[] = { |
646 | GNUNET_SQ_query_param_auto_from_type (zone), | 647 | GNUNET_SQ_query_param_auto_from_type (zone), |
647 | GNUNET_SQ_query_param_uint64 (&serial), | 648 | GNUNET_SQ_query_param_uint64 (&rowid), |
648 | GNUNET_SQ_query_param_uint64 (&limit), | 649 | GNUNET_SQ_query_param_uint64 (&limit), |
649 | GNUNET_SQ_query_param_end | 650 | GNUNET_SQ_query_param_end |
650 | }; | 651 | }; |