]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: add a new flag to declare static registrations
authorWilly Tarreau <w@1wt.eu>
Tue, 5 Aug 2025 16:46:34 +0000 (18:46 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 6 Aug 2025 17:20:26 +0000 (19:20 +0200)
We must not free these ones when destroying a pool, so let's dedicate
them a flag to mention that they are static. For now we don't have any
such.

include/haproxy/pool-t.h
src/pool.c

index 1801f135bed4fb7853e6d040e15538c2b2cd540b..524c871b82cced8f9f673a442076d68ded7d441a 100644 (file)
@@ -28,6 +28,7 @@
 #define MEM_F_SHARED   0x1
 #define MEM_F_EXACT    0x2
 #define MEM_F_UAF      0x4
+#define MEM_F_STATREG  0x8 /* static registration: do not free it! */
 
 /* A special pointer for the pool's free_list that indicates someone is
  * currently manipulating it. Serves as a short-lived lock.
index 159a28a1b2c31adbddc025f3247ac84a1b3bcace..43359403fbd8c6ff60d07fae833d42cd9ae6c1ea 100644 (file)
@@ -1049,7 +1049,8 @@ void *pool_destroy(struct pool_head *pool)
 
                        list_for_each_entry_safe(reg, back, &pool->regs, list) {
                                LIST_DELETE(&reg->list);
-                               free(reg);
+                               if (!(reg->flags & MEM_F_STATREG))
+                                       free(reg);
                        }
 
                        LIST_DELETE(&pool->list);