]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] Free tcp rules on denint()
authorSimon Horman <horms@verge.net.au>
Fri, 15 Jul 2011 04:14:09 +0000 (13:14 +0900)
committerWilly Tarreau <w@1wt.eu>
Mon, 18 Jul 2011 08:21:23 +0000 (10:21 +0200)
The motivation for this is that when soft-restart is merged
it will be come more important to free all relevant memory in deinit()

Discovered using valgrind.

src/haproxy.c

index 321769515be3b1f4a608ae221fc23384d9cbf394..da9f8c63d04ed06f936c3f4e489c3678977221fa 100644 (file)
@@ -66,6 +66,8 @@
 
 #include <types/capture.h>
 #include <types/global.h>
+#include <types/proto_tcp.h>
+#include <types/acl.h>
 
 #include <proto/auth.h>
 #include <proto/acl.h>
@@ -672,6 +674,29 @@ void init(int argc, char **argv)
 
 }
 
+static void deinit_tcp_rules(struct list *rules)
+{
+       struct tcp_rule *trule, *truleb;
+       struct acl_term_suite *suite, *suiteb;
+       struct acl_term *term, *termb;
+
+       list_for_each_entry_safe(trule, truleb, rules, list) {
+               if (trule->cond) {
+                       list_for_each_entry_safe(suite, suiteb, &trule->cond->suites, list) {
+                               list_for_each_entry_safe(term, termb, &suite->terms, list) {
+                                       LIST_DEL(&term->list);
+                                       free(term);
+                               }
+                               LIST_DEL(&suite->list);
+                               free(suite);
+                       }
+               }
+               LIST_DEL(&trule->list);
+               free(trule->cond);
+               free(trule);
+       }
+}
+
 void deinit(void)
 {
        struct proxy *p = proxy, *p0;
@@ -791,6 +816,9 @@ void deinit(void)
                        free(rdr);
                }
 
+               deinit_tcp_rules(&p->tcp_req.inspect_rules);
+               deinit_tcp_rules(&p->tcp_req.l4_rules);
+
                free(p->appsession_name);
 
                h = p->req_cap;