mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 23:56:57 +02:00
MINOR: proxy: use the global file names for conf->file
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.
This commit is contained in:
parent
9ab21a3c2d
commit
b325453c36
@ -414,7 +414,7 @@ struct proxy {
|
|||||||
int no_options2; /* PR_O2_* */
|
int no_options2; /* PR_O2_* */
|
||||||
|
|
||||||
struct {
|
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 */
|
struct eb32_node id; /* place in the tree of used IDs */
|
||||||
int line; /* line where the section appears */
|
int line; /* line where the section appears */
|
||||||
struct eb_root used_listener_id;/* list of listener IDs in use */
|
struct eb_root used_listener_id;/* list of listener IDs in use */
|
||||||
|
@ -574,8 +574,8 @@ static int init_peers_frontend(const char *file, int linenum,
|
|||||||
out:
|
out:
|
||||||
if (id && !p->id)
|
if (id && !p->id)
|
||||||
p->id = strdup(id);
|
p->id = strdup(id);
|
||||||
free(p->conf.file);
|
drop_file_name(&p->conf.file);
|
||||||
p->conf.args.file = p->conf.file = strdup(file);
|
p->conf.args.file = p->conf.file = copy_file_name(file);
|
||||||
if (linenum != -1)
|
if (linenum != -1)
|
||||||
p->conf.args.line = p->conf.line = linenum;
|
p->conf.args.line = p->conf.line = linenum;
|
||||||
|
|
||||||
|
@ -3293,7 +3293,7 @@ int mworker_cli_proxy_create()
|
|||||||
mworker_proxy->mode = PR_MODE_CLI;
|
mworker_proxy->mode = PR_MODE_CLI;
|
||||||
mworker_proxy->maxconn = 10; /* default to 10 concurrent connections */
|
mworker_proxy->maxconn = 10; /* default to 10 concurrent connections */
|
||||||
mworker_proxy->timeout.client = 0; /* no timeout */
|
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->conf.line = 0;
|
||||||
mworker_proxy->accept = frontend_accept;
|
mworker_proxy->accept = frontend_accept;
|
||||||
mworker_proxy-> lbprm.algo = BE_LB_ALGO_NONE;
|
mworker_proxy-> lbprm.algo = BE_LB_ALGO_NONE;
|
||||||
|
@ -5886,7 +5886,7 @@ int cfg_parse_log_forward(const char *file, int linenum, char **args, int kwm)
|
|||||||
init_new_proxy(px);
|
init_new_proxy(px);
|
||||||
px->next = cfg_log_forward;
|
px->next = cfg_log_forward;
|
||||||
cfg_log_forward = px;
|
cfg_log_forward = px;
|
||||||
px->conf.file = strdup(file);
|
px->conf.file = copy_file_name(file);
|
||||||
px->conf.line = linenum;
|
px->conf.line = linenum;
|
||||||
px->mode = PR_MODE_SYSLOG;
|
px->mode = PR_MODE_SYSLOG;
|
||||||
px->fe_counters.last_change = ns_to_sec(now_ns);
|
px->fe_counters.last_change = ns_to_sec(now_ns);
|
||||||
|
@ -203,7 +203,7 @@ static inline void proxy_free_common(struct proxy *px)
|
|||||||
struct lf_expr *lf, *lfb;
|
struct lf_expr *lf, *lfb;
|
||||||
|
|
||||||
ha_free(&px->id);
|
ha_free(&px->id);
|
||||||
ha_free(&px->conf.file);
|
drop_file_name(&px->conf.file);
|
||||||
ha_free(&px->check_command);
|
ha_free(&px->check_command);
|
||||||
ha_free(&px->check_path);
|
ha_free(&px->check_path);
|
||||||
ha_free(&px->cookie_name);
|
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;
|
curproxy->conf.args.line = curproxy->conf.line = linenum;
|
||||||
|
|
||||||
return curproxy;
|
return curproxy;
|
||||||
|
@ -3496,7 +3496,7 @@ static int resolvers_new(struct resolvers **resolvers, const char *id, const cha
|
|||||||
resolvers_setup_proxy(p);
|
resolvers_setup_proxy(p);
|
||||||
p->parent = r;
|
p->parent = r;
|
||||||
p->id = strdup(id);
|
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;
|
p->conf.args.line = p->conf.line = linenum;
|
||||||
r->px = p;
|
r->px = p;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user