From fbfeb591f774a9dec8aee9c08efa50b1dcf039c0 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Thu, 10 Apr 2025 10:37:33 +0200 Subject: [PATCH] MINOR: proxy: add deinit_proxy() helper func Same as free_proxy(), but does not free the base proxy pointer (ie: the proxy itself may not be allocated) Goal is to be able to cleanup statically allocated dummy proxies. --- include/haproxy/proxy.h | 1 + src/proxy.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/haproxy/proxy.h b/include/haproxy/proxy.h index 1666b00ba..c6c41260c 100644 --- a/include/haproxy/proxy.h +++ b/include/haproxy/proxy.h @@ -51,6 +51,7 @@ int resume_proxy(struct proxy *p); void stop_proxy(struct proxy *p); int stream_set_backend(struct stream *s, struct proxy *be); +void deinit_proxy(struct proxy *p); void free_proxy(struct proxy *p); const char *proxy_cap_str(int cap); const char *proxy_mode_str(int mode); diff --git a/src/proxy.c b/src/proxy.c index f1f2a3f03..cd7caf073 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -284,7 +284,10 @@ static inline void proxy_free_common(struct proxy *px) px->uri_auth = NULL; } -void free_proxy(struct proxy *p) +/* deinit all

proxy members, but doesn't touch to the parent pointer + * itself + */ +void deinit_proxy(struct proxy *p) { struct server *s; struct cap_hdr *h,*h_next; @@ -424,6 +427,12 @@ void free_proxy(struct proxy *p) HA_RWLOCK_DESTROY(&p->lock); proxy_unref_defaults(p); +} + +/* deinit and free

proxy */ +void free_proxy(struct proxy *p) +{ + deinit_proxy(p); ha_free(&p); }