]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: pools: also retrieve file and line for direct callers of create_pool()
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Aug 2025 07:50:42 +0000 (09:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 6 Aug 2025 17:20:34 +0000 (19:20 +0200)
Just like previous patch, we want to retrieve the location of the caller.
For this we turn create_pool() into a macro that collects __FILE__ and
__LINE__ and passes them to the now renamed function create_pool_with_loc().

Now the remaining ~30 pools also have their location stored.

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

index 108e00e5f4b2caebc6cac5fcc806d0e278814320..a089f035a781a3d28bcf137f45de7e70a583c784 100644 (file)
@@ -143,7 +143,7 @@ unsigned long long pool_total_allocated(void);
 unsigned long long pool_total_used(void);
 void pool_flush(struct pool_head *pool);
 void pool_gc(struct pool_head *pool_ctx);
-struct pool_head *create_pool(const char *name, unsigned int size, unsigned int flags);
+struct pool_head *create_pool_with_loc(const char *name, unsigned int size, unsigned int flags, const char *file, unsigned int line);
 struct pool_head *create_pool_from_reg(const char *name, struct pool_registration *reg);
 void create_pool_callback(struct pool_head **ptr, char *name, struct pool_registration *reg);
 void *pool_destroy(struct pool_head *pool);
@@ -152,6 +152,9 @@ void *__pool_alloc(struct pool_head *pool, unsigned int flags);
 void __pool_free(struct pool_head *pool, void *ptr);
 void pool_inspect_item(const char *msg, struct pool_head *pool, const void *item, const void *caller, ssize_t ofs);
 
+#define create_pool(name, size, flags) \
+       create_pool_with_loc(name, size, flags, __FILE__, __LINE__)
+
 
 /****************** Thread-local cache management ******************/
 
index c3eb98189243ea7018ee288f7b2a060255b5f9c5..3275bcb9bab6d914bae62b4bf89cf8a1f1b3a475 100644 (file)
@@ -291,8 +291,11 @@ static int mem_should_fail(const struct pool_head *pool)
  *   - MEM_F_SHARED to indicate that the pool may be shared with other users
  *   - MEM_F_EXACT to indicate that the size must not be rounded up
  * The name must be a stable pointer during all the program's life time.
+ * The file and line are passed to store the registration location in the
+ * registration struct. Use create_pool() instead which does it for free.
  */
-struct pool_head *create_pool(const char *name, unsigned int size, unsigned int flags)
+struct pool_head *create_pool_with_loc(const char *name, unsigned int size, unsigned int flags,
+                                      const char *file, unsigned int line)
 {
        struct pool_registration *reg;
        struct pool_head *pool;
@@ -302,6 +305,8 @@ struct pool_head *create_pool(const char *name, unsigned int size, unsigned int
                return NULL;
 
        reg->name = name;
+       reg->file = file;
+       reg->line = line;
        reg->size = size;
        reg->flags = flags;
        reg->align = 0;