]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] proxy: stats frontend and peers were missing many initializers
authorWilly Tarreau <w@1wt.eu>
Thu, 28 Jul 2011 23:49:03 +0000 (01:49 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 29 Jul 2011 00:00:19 +0000 (02:00 +0200)
This was revealed with one of the very latest patches which caused
the listener_queue not to be initialized on the stats socket frontend.
And in fact a number of other ones were missing too. This is getting so
boring that now we'll always make use of the same function to initialize
any proxy. Doing so has even saved about 500 bytes on the binary due to
the avoided code redundancy.

No backport is needed.

include/proto/proxy.h
src/cfgparse.c
src/dumpstats.c
src/proxy.c

index afcfa0aab696385bb57d0b4f9eb812360bd3ab23..2b5328c680bd0d687583b26b8d62be72c4de7644 100644 (file)
@@ -43,6 +43,7 @@ struct proxy *findproxy_mode(const char *name, int mode, int cap);
 struct proxy *findproxy(const char *name, int cap);
 struct server *findserver(const struct proxy *px, const char *name);
 int proxy_cfg_ensure_no_http(struct proxy *curproxy);
+void init_new_proxy(struct proxy *p);
 int get_backend_server(const char *bk_name, const char *sv_name,
                       struct proxy **bk, struct server **sv);
 
index fd81a203e8fbf4b200d12bf22071340763b3c045..04373acf6e77c9f79aceb425cd8777557b49bce9 100644 (file)
@@ -1020,34 +1020,6 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
        return err_code;
 }
 
-/* Perform the most basic initialization of a proxy :
- * memset(), list_init(*), reset_timeouts(*).
- */
-static void init_new_proxy(struct proxy *p)
-{
-       memset(p, 0, sizeof(struct proxy));
-       LIST_INIT(&p->pendconns);
-       LIST_INIT(&p->acl);
-       LIST_INIT(&p->http_req_rules);
-       LIST_INIT(&p->block_cond);
-       LIST_INIT(&p->redirect_rules);
-       LIST_INIT(&p->mon_fail_cond);
-       LIST_INIT(&p->switching_rules);
-       LIST_INIT(&p->persist_rules);
-       LIST_INIT(&p->sticking_rules);
-       LIST_INIT(&p->storersp_rules);
-       LIST_INIT(&p->tcp_req.inspect_rules);
-       LIST_INIT(&p->tcp_rep.inspect_rules);
-       LIST_INIT(&p->tcp_req.l4_rules);
-       LIST_INIT(&p->req_add);
-       LIST_INIT(&p->rsp_add);
-       LIST_INIT(&p->listener_queue);
-
-       /* Timeouts are defined as -1 */
-       proxy_reset_timeouts(p);
-       p->tcp_rep.inspect_delay = TICK_ETERNITY;
-}
-
 void init_default_instance()
 {
        init_new_proxy(&defproxy);
@@ -1278,18 +1250,9 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                                        err_code |= ERR_ALERT | ERR_ABORT;
                                        goto out;
                                }
-                               curpeers->peers_fe->parent = curpeers;
-
-                               LIST_INIT(&(curpeers->peers_fe)->pendconns);
-                               LIST_INIT(&(curpeers->peers_fe)->acl);
-                               LIST_INIT(&(curpeers->peers_fe)->block_cond);
-                               LIST_INIT(&(curpeers->peers_fe)->redirect_rules);
-                               LIST_INIT(&(curpeers->peers_fe)->mon_fail_cond);
-                               LIST_INIT(&(curpeers->peers_fe)->switching_rules);
-                               LIST_INIT(&(curpeers->peers_fe)->tcp_req.inspect_rules);
-                               LIST_INIT(&(curpeers->peers_fe)->tcp_rep.inspect_rules);
 
-                               proxy_reset_timeouts(curpeers->peers_fe);
+                               init_new_proxy(curpeers->peers_fe);
+                               curpeers->peers_fe->parent = curpeers;
 
                                curpeers->peers_fe->last_change = now.tv_sec;
                                curpeers->peers_fe->id = strdup(args[1]);
index 96999852c8b867cbfb09cd238ee35c5ffea12705..9caebdd599f2d0ae3ec57dc9f5402d6c737d3838 100644 (file)
@@ -153,18 +153,7 @@ static struct proxy *alloc_stats_fe(const char *name)
        if (!fe)
                return NULL;
 
-       LIST_INIT(&fe->pendconns);
-       LIST_INIT(&fe->acl);
-       LIST_INIT(&fe->block_cond);
-       LIST_INIT(&fe->redirect_rules);
-       LIST_INIT(&fe->mon_fail_cond);
-       LIST_INIT(&fe->switching_rules);
-       LIST_INIT(&fe->tcp_req.inspect_rules);
-
-       /* Timeouts are defined as -1, so we cannot use the zeroed area
-        * as a default value.
-        */
-       proxy_reset_timeouts(fe);
+       init_new_proxy(fe);
 
        fe->last_change = now.tv_sec;
        fe->id = strdup("GLOBAL");
index 7c22a75fc0df2ffe5e54ec51adb154232cab532b..3b56c86ea2d2d13d1aeb05c626de282585855e25 100644 (file)
@@ -403,6 +403,35 @@ int proxy_cfg_ensure_no_http(struct proxy *curproxy)
        return 0;
 }
 
+/* Perform the most basic initialization of a proxy :
+ * memset(), list_init(*), reset_timeouts(*).
+ * Any new proxy should be initialized via this function.
+ */
+void init_new_proxy(struct proxy *p)
+{
+       memset(p, 0, sizeof(struct proxy));
+       LIST_INIT(&p->pendconns);
+       LIST_INIT(&p->acl);
+       LIST_INIT(&p->http_req_rules);
+       LIST_INIT(&p->block_cond);
+       LIST_INIT(&p->redirect_rules);
+       LIST_INIT(&p->mon_fail_cond);
+       LIST_INIT(&p->switching_rules);
+       LIST_INIT(&p->persist_rules);
+       LIST_INIT(&p->sticking_rules);
+       LIST_INIT(&p->storersp_rules);
+       LIST_INIT(&p->tcp_req.inspect_rules);
+       LIST_INIT(&p->tcp_rep.inspect_rules);
+       LIST_INIT(&p->tcp_req.l4_rules);
+       LIST_INIT(&p->req_add);
+       LIST_INIT(&p->rsp_add);
+       LIST_INIT(&p->listener_queue);
+
+       /* Timeouts are defined as -1 */
+       proxy_reset_timeouts(p);
+       p->tcp_rep.inspect_delay = TICK_ETERNITY;
+}
+
 /*
  * This function creates all proxy sockets. It should be done very early,
  * typically before privileges are dropped. The sockets will be registered