From 2bf23f075a55fb534c008f80e1ce020c613f7d74 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Sun, 25 Feb 2024 17:37:35 +0100 Subject: PEERSTORE: Fix iteration bugs in iteration --- src/service/peerstore/gnunet-service-peerstore.c | 2 +- src/service/peerstore/peerstore_api.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/service/peerstore/gnunet-service-peerstore.c b/src/service/peerstore/gnunet-service-peerstore.c index 72c7b035f..37af3af56 100644 --- a/src/service/peerstore/gnunet-service-peerstore.c +++ b/src/service/peerstore/gnunet-service-peerstore.c @@ -646,7 +646,7 @@ handle_iterate_stop (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ITERATION_STOP message\n"); - rid = ntohl (zis_msg->rid); + rid = ntohs (zis_msg->rid); for (ic = pc->op_head; NULL != ic; ic = ic->next) if (ic->request_id == rid) break; diff --git a/src/service/peerstore/peerstore_api.c b/src/service/peerstore/peerstore_api.c index a69237c9b..3b945928a 100644 --- a/src/service/peerstore/peerstore_api.c +++ b/src/service/peerstore/peerstore_api.c @@ -864,7 +864,7 @@ hello_add_iter (void *cls, const struct GNUNET_PEERSTORE_Record *record, struct GNUNET_PEERSTORE_StoreHelloContext *huc = cls; struct GNUNET_TIME_Absolute hello_exp = GNUNET_HELLO_builder_get_expiration_time (huc->hello); - if (NULL == record) + if ((NULL == record) && (NULL == emsg)) { /** If we ever get here, we are newer than the existing record * or the only/first record. @@ -881,6 +881,12 @@ hello_add_iter (void *cls, const struct GNUNET_PEERSTORE_Record *record, huc); return; } + if (NULL != emsg) + { + LOG (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); + GNUNET_PEERSTORE_iteration_next (huc->ic, 1); + return; + } if (GNUNET_TIME_absolute_cmp (record->expiry, >, hello_exp)) { huc->cont (huc->cont_cls, GNUNET_OK); @@ -889,6 +895,7 @@ hello_add_iter (void *cls, const struct GNUNET_PEERSTORE_Record *record, GNUNET_free (huc); return; } + GNUNET_PEERSTORE_iteration_next (huc->ic, 1); } -- cgit v1.2.3