From 5db139d2dc74f0d4450d3d7f45c3febc4b5dfc1f Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 16 Aug 2025 13:02:08 +0200 Subject: ipcpd: Add cleanup of DHT replication lists The replication/republication lists could leak on shutdown. Added cleanup handlers for them. Signed-off-by: Dimitri Staessens --- src/ipcpd/unicast/dir/dht.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ipcpd/unicast/dir/dht.c b/src/ipcpd/unicast/dir/dht.c index d0523eee..656b8b94 100644 --- a/src/ipcpd/unicast/dir/dht.c +++ b/src/ipcpd/unicast/dir/dht.c @@ -3646,6 +3646,11 @@ static void dht_kv_update_replication_times(const uint8_t * key, pthread_rwlock_unlock(&dht.db.lock); } +static void __cleanup_value_list(void * o) +{ + return value_list_destroy((struct list_head *) o); +} + static void dht_kv_replicate_values(const uint8_t * key, struct list_head * repl, struct list_head * rebl) @@ -3656,6 +3661,9 @@ static void dht_kv_replicate_values(const uint8_t * key, clock_gettime(CLOCK_REALTIME_COARSE, &now); + pthread_cleanup_push(__cleanup_value_list, repl); + pthread_cleanup_push(__cleanup_value_list, rebl); + list_for_each_safe(p, h, repl) { struct val_entry * v; v = list_entry(p, struct val_entry, next); @@ -3668,6 +3676,9 @@ static void dht_kv_replicate_values(const uint8_t * key, dht_kv_republish_value(key, v, &now); } + pthread_cleanup_pop(false); + pthread_cleanup_pop(false); + /* removes non-replicated items from the list */ dht_kv_update_replication_times(key, repl, rebl, &now); -- cgit v1.2.3