]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxy: use the global file names for conf->file
authorWilly Tarreau <w@1wt.eu>
Thu, 19 Sep 2024 13:35:11 +0000 (15:35 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Sep 2024 13:38:19 +0000 (15:38 +0200)
Proxy file names are assigned a bit everywhere (resolvers, peers,
cli, logs, proxy). All these elements were enumerated and now use
copy_file_name(). The only ha_free() call was turned to drop_file_name().

As a bonus side effect, a 300k backend config saved 14 MB of RAM.

include/haproxy/proxy-t.h
src/cfgparse.c
src/cli.c
src/log.c
src/proxy.c
src/resolvers.c

index 74b4ab6d643bc7b53ef1a38c2e676cc753e1e21c..a1e01dd4e1f0ac262f3b859abb1f861afaef1ceb 100644 (file)
@@ -414,7 +414,7 @@ struct proxy {
        int no_options2;                        /* PR_O2_* */
 
        struct {
-               char *file;                     /* file where the section appears */
+               const char *file;               /* file where the section appears */
                struct eb32_node id;            /* place in the tree of used IDs */
                int line;                       /* line where the section appears */
                struct eb_root used_listener_id;/* list of listener IDs in use */
index d90fdc5eab5d060d3a930e9189eb452e60ed58b4..27c1119c0ccb4aac082b79d7cdef99fa0b3a4bc0 100644 (file)
@@ -574,8 +574,8 @@ static int init_peers_frontend(const char *file, int linenum,
  out:
        if (id && !p->id)
                p->id = strdup(id);
-       free(p->conf.file);
-       p->conf.args.file = p->conf.file = strdup(file);
+       drop_file_name(&p->conf.file);
+       p->conf.args.file = p->conf.file = copy_file_name(file);
        if (linenum != -1)
                p->conf.args.line = p->conf.line = linenum;
 
index fafe6a34aa042f3885212dd73e1334e774f474be..5d8e7ae91987ff1a21b5c7eeba1e1a4ef56a270a 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -3293,7 +3293,7 @@ int mworker_cli_proxy_create()
        mworker_proxy->mode = PR_MODE_CLI;
        mworker_proxy->maxconn = 10;                 /* default to 10 concurrent connections */
        mworker_proxy->timeout.client = 0; /* no timeout */
-       mworker_proxy->conf.file = strdup("MASTER");
+       mworker_proxy->conf.file = copy_file_name("MASTER");
        mworker_proxy->conf.line = 0;
        mworker_proxy->accept = frontend_accept;
        mworker_proxy-> lbprm.algo = BE_LB_ALGO_NONE;
index 8b6e9b61f70eb1338cebef24af2952027e665ebf..883be829a78676f881211c21e206657fba71751a 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -5886,7 +5886,7 @@ int cfg_parse_log_forward(const char *file, int linenum, char **args, int kwm)
                init_new_proxy(px);
                px->next = cfg_log_forward;
                cfg_log_forward = px;
-               px->conf.file = strdup(file);
+               px->conf.file = copy_file_name(file);
                px->conf.line = linenum;
                px->mode = PR_MODE_SYSLOG;
                px->fe_counters.last_change = ns_to_sec(now_ns);
index e719d86e23e77774d8ad840b59346d3544269d4a..a6e94f66cba9ee5437ef91642a53c0fb58f1c522 100644 (file)
@@ -203,7 +203,7 @@ static inline void proxy_free_common(struct proxy *px)
        struct lf_expr *lf, *lfb;
 
        ha_free(&px->id);
-       ha_free(&px->conf.file);
+       drop_file_name(&px->conf.file);
        ha_free(&px->check_command);
        ha_free(&px->check_path);
        ha_free(&px->cookie_name);
@@ -1850,7 +1850,7 @@ struct proxy *parse_new_proxy(const char *name, unsigned int cap,
                }
        }
 
-       curproxy->conf.args.file = curproxy->conf.file = strdup(file);
+       curproxy->conf.args.file = curproxy->conf.file = copy_file_name(file);
        curproxy->conf.args.line = curproxy->conf.line = linenum;
 
        return curproxy;
index 99b4ef0cf5ea2be9e4ae5bf28c0c84a4e6a15317..9e28bf686713c1340162f43f480294870153a41b 100644 (file)
@@ -3496,7 +3496,7 @@ static int resolvers_new(struct resolvers **resolvers, const char *id, const cha
        resolvers_setup_proxy(p);
        p->parent = r;
        p->id = strdup(id);
-       p->conf.args.file = p->conf.file = strdup(file);
+       p->conf.args.file = p->conf.file = copy_file_name(file);
        p->conf.args.line = p->conf.line = linenum;
        r->px = p;