From: Aurelien DARRAGON Date: Thu, 10 Apr 2025 08:37:33 +0000 (+0200) Subject: MINOR: proxy: add deinit_proxy() helper func X-Git-Tag: v3.2-dev10~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fbfeb591f774a9dec8aee9c08efa50b1dcf039c0;p=thirdparty%2Fhaproxy.git 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. --- 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); }