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.
This commit is contained in:
Aurelien DARRAGON 2025-04-10 10:37:33 +02:00
parent 4194f756de
commit fbfeb591f7
2 changed files with 11 additions and 1 deletions

View File

@ -51,6 +51,7 @@ int resume_proxy(struct proxy *p);
void stop_proxy(struct proxy *p); void stop_proxy(struct proxy *p);
int stream_set_backend(struct stream *s, struct proxy *be); int stream_set_backend(struct stream *s, struct proxy *be);
void deinit_proxy(struct proxy *p);
void free_proxy(struct proxy *p); void free_proxy(struct proxy *p);
const char *proxy_cap_str(int cap); const char *proxy_cap_str(int cap);
const char *proxy_mode_str(int mode); const char *proxy_mode_str(int mode);

View File

@ -284,7 +284,10 @@ static inline void proxy_free_common(struct proxy *px)
px->uri_auth = NULL; 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 server *s;
struct cap_hdr *h,*h_next; struct cap_hdr *h,*h_next;
@ -424,6 +427,12 @@ void free_proxy(struct proxy *p)
HA_RWLOCK_DESTROY(&p->lock); HA_RWLOCK_DESTROY(&p->lock);
proxy_unref_defaults(p); proxy_unref_defaults(p);
}
/* deinit and free <p> proxy */
void free_proxy(struct proxy *p)
{
deinit_proxy(p);
ha_free(&p); ha_free(&p);
} }