From: Aurelien DARRAGON Date: Thu, 23 Nov 2023 15:27:45 +0000 (+0100) Subject: MINOR: proxy: add free_server_rules() helper function X-Git-Tag: v2.9-dev12~98 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2629ebd4edc098b3cfd4254d23debef65f1fab1;p=thirdparty%2Fhaproxy.git MINOR: proxy: add free_server_rules() helper function Take the px->server_rules freeing part out of free_proxy() and make it a dedicated helper function so that it becomes possible to use it from anywhere. --- diff --git a/include/haproxy/proxy.h b/include/haproxy/proxy.h index e67ea2c059..efdfa21540 100644 --- a/include/haproxy/proxy.h +++ b/include/haproxy/proxy.h @@ -87,6 +87,7 @@ struct proxy *cli_find_frontend(struct appctx *appctx, const char *arg); struct proxy *cli_find_frontend(struct appctx *appctx, const char *arg); int resolve_stick_rule(struct proxy *curproxy, struct sticking_rule *mrule); void free_stick_rules(struct list *rules); +void free_server_rules(struct list *srules); /* * This function returns a string containing the type of the proxy in a format diff --git a/src/proxy.c b/src/proxy.c index 467bcd2f6c..9beb232dae 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -189,6 +189,19 @@ static void free_logformat_list(struct list *lfs) } } +void free_server_rules(struct list *srules) +{ + struct server_rule *srule, *sruleb; + + list_for_each_entry_safe(srule, sruleb, srules, list) { + LIST_DELETE(&srule->list); + free_acl_cond(srule->cond); + free_logformat_list(&srule->expr); + free(srule->file); + free(srule); + } +} + void free_proxy(struct proxy *p) { struct server *s; @@ -197,7 +210,6 @@ void free_proxy(struct proxy *p) struct bind_conf *bind_conf, *bind_back; struct acl_cond *cond, *condb; struct acl *acl, *aclb; - struct server_rule *srule, *sruleb; struct switching_rule *rule, *ruleb; struct redirect_rule *rdr, *rdrb; struct logger *log, *logb; @@ -260,13 +272,7 @@ void free_proxy(struct proxy *p) free(acl); } - list_for_each_entry_safe(srule, sruleb, &p->server_rules, list) { - LIST_DELETE(&srule->list); - free_acl_cond(srule->cond); - free_logformat_list(&srule->expr); - free(srule->file); - free(srule); - } + free_server_rules(&p->server_rules); list_for_each_entry_safe(rule, ruleb, &p->switching_rules, list) { LIST_DELETE(&rule->list);