diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2025-08-16 13:02:08 +0200 |
---|---|---|
committer | Dimitri Staessens <dimitri@ouroboros.rocks> | 2025-08-23 10:13:36 +0200 |
commit | 5db139d2dc74f0d4450d3d7f45c3febc4b5dfc1f (patch) | |
tree | ed3bc44aeef63d824b7ec15d4805ed72a00832ae | |
parent | 575adac4acacf7d02395df0322ff5f03b7b82aaf (diff) | |
download | ouroboros-5db139d2dc74f0d4450d3d7f45c3febc4b5dfc1f.tar.gz ouroboros-5db139d2dc74f0d4450d3d7f45c3febc4b5dfc1f.zip |
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 <dimitri@ouroboros.rocks>
-rw-r--r-- | src/ipcpd/unicast/dir/dht.c | 11 |
1 files changed, 11 insertions, 0 deletions
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); |