From 657fdee8e909bd50fcc0b809b454cf1ad551384b Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sun, 16 Aug 2026 18:05:20 +0000 Subject: ipcpd: Fix next value iteration in DHT There was a bug in the loop where only the last entry was checked. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/unicast/dir/dht.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/ipcpd/unicast/dir/dht.c') diff --git a/src/ipcpd/unicast/dir/dht.c b/src/ipcpd/unicast/dir/dht.c index c2cd33aa..9d60ce30 100644 --- a/src/ipcpd/unicast/dir/dht.c +++ b/src/ipcpd/unicast/dir/dht.c @@ -3512,7 +3512,7 @@ static int dht_kv_next_values(uint8_t * key, struct timespec now; struct list_head * p; struct list_head * h; - struct dht_entry * e = NULL; + struct dht_entry * e; assert(key != NULL); assert(repl != NULL); @@ -3525,20 +3525,19 @@ static int dht_kv_next_values(uint8_t * key, pthread_rwlock_rdlock(&dht.db.lock); - if (llist_is_empty(&dht.db.kv.ll)) - goto no_entries; - llist_for_each_safe(p, h, &dht.db.kv.ll) { e = list_entry(p, struct dht_entry, next); - if (IS_CLOSER(e->key, key)) + if (!IS_CLOSER(key, e->key)) continue; /* Already processed */ - } - if (e != NULL) { memcpy(key, e->key, dht.id.len); + dht_entry_get_repl_lists(e, repl, rebl, &now); + + if (!list_is_empty(repl) || !list_is_empty(rebl)) + break; } - no_entries: + pthread_rwlock_unlock(&dht.db.lock); return list_is_empty(repl) && list_is_empty(rebl) ? -ENOENT : 0; -- cgit v1.2.3