]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxy: add free_server_rules() helper function
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 23 Nov 2023 15:27:45 +0000 (16:27 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 24 Nov 2023 15:27:55 +0000 (16:27 +0100)
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.

include/haproxy/proxy.h
src/proxy.c

index e67ea2c059d165ba04eada563e9d3872bbb697d8..efdfa21540f6278f362e612c91fa9f1e2fc6dc9d 100644 (file)
@@ -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
index 467bcd2f6c0665c767f1373d510928cb04dfe587..9beb232dae56596107a8a7a0f03b6d4f28f98698 100644 (file)
@@ -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);