]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxy: add deinit_proxy() helper func
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 10 Apr 2025 08:37:33 +0000 (10:37 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 10 Apr 2025 20:10:31 +0000 (22:10 +0200)
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
src/proxy.c

index 1666b00ba90af1cd4928b2ee62f350e05bb28444..c6c41260ca81ed81a39a47710f4b557c0d78bf2b 100644 (file)
@@ -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);
index f1f2a3f031af44f0f51bc2e2c22488705f25ab4c..cd7caf073a7a25a3ffbe583f9327f53277a06292 100644 (file)
@@ -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 <p> 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 <p> proxy */
+void free_proxy(struct proxy *p)
+{
+       deinit_proxy(p);
        ha_free(&p);
 }