]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cfgparse: move defproxy to cfgparse-listen as a static
authorWilly Tarreau <w@1wt.eu>
Fri, 12 Feb 2021 11:29:28 +0000 (12:29 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 12 Feb 2021 15:23:46 +0000 (16:23 +0100)
We don't want to expose this one anymore as we'll soon keep multiple
default proxies. Let's move it inside the parser which is the only
place which still uses it, and initialize it on the fly once needed
instead of doing it at boot time.

include/haproxy/cfgparse.h
src/cfgparse-listen.c
src/cfgparse.c
src/haproxy.c

index a1476fad68d8677271844d28f783bb37bba08332..186ecf75b74ec210aee2921852ed1f1534621a92 100644 (file)
@@ -84,7 +84,6 @@ extern int cfg_maxconn;
 extern char *cfg_scope;
 extern struct cfg_kw_list cfg_keywords;
 extern char *cursection;
-extern struct proxy defproxy;
 
 int cfg_parse_global(const char *file, int linenum, char **args, int inv);
 int cfg_parse_listen(const char *file, int linenum, char **args, int inv);
index edcc041382052c5a40ca5ccd0bbf54be3f1d1fcb..ffe793156344d2889ae3650782c55b9e3cfa2771 100644 (file)
@@ -33,6 +33,9 @@
 #include <haproxy/tcpcheck.h>
 #include <haproxy/uri_auth.h>
 
+
+static struct proxy defproxy; /* fake proxy used to assign default values on all instances */
+
 /* Report a warning if a rule is placed after a 'tcp-request session' rule.
  * Return 1 if the warning has been emitted, otherwise 0.
  */
@@ -177,6 +180,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
        char *errmsg = NULL;
        struct bind_conf *bind_conf;
 
+       if (defproxy.obj_type != OBJ_TYPE_PROXY) {
+               /* defproxy not initialized yet */
+               init_new_proxy(&defproxy);
+               proxy_preset_defaults(&defproxy);
+       }
+
        if (strcmp(args[0], "listen") == 0)
                rc = PR_CAP_LISTEN;
        else if (strcmp(args[0], "frontend") == 0)
index 9f76878f0776a8a98428b05f06e66beeaf62f26f..0ddbab0008f8103e2b53eac5e0c4408d30d89b0f 100644 (file)
@@ -89,7 +89,6 @@ struct list sections = LIST_HEAD_INIT(sections);
 struct list postparsers = LIST_HEAD_INIT(postparsers);
 
 char *cursection = NULL;
-struct proxy defproxy = { };           /* fake proxy used to assign default values on all instances */
 int cfg_maxpconn = 0;                   /* # of simultaneous connections per proxy (-N) */
 int cfg_maxconn = 0;                   /* # of simultaneous connections, (-n) */
 char *cfg_scope = NULL;                 /* the current scope during the configuration parsing */
index 1bac1c51fd65c0739a6290e771f0c3a93d5a5ac8..69ddb903561767a5796dade40576f390ba42deb5 100644 (file)
@@ -1822,9 +1822,6 @@ static void init(int argc, char **argv)
 
        global.maxsock = 10; /* reserve 10 fds ; will be incremented by socket eaters */
 
-       init_new_proxy(&defproxy);
-       proxy_preset_defaults(&defproxy);
-
        /* in wait mode, we don't try to read the configuration files */
        if (!(global.mode & MODE_MWORKER_WAIT)) {
                char *env_cfgfiles = NULL;