REORG: config: extract the proxy parser into cfgparse-listen.c
This was the largest function of the whole file, taking a rough second to build alone. Let's move it to a distinct file along with a few dependencies. Doing so saved about 2 seconds on the total build time.
This commit is contained in:
parent
36b9e222bb
commit
3a1f5fda10
2
Makefile
2
Makefile
@ -904,7 +904,7 @@ all: haproxy $(EXTRA)
|
||||
endif
|
||||
|
||||
OBJS = src/proto_http.o src/cfgparse.o src/cfgparse-global.o \
|
||||
src/server.o src/stream.o \
|
||||
src/cfgparse-listen.o src/server.o src/stream.o \
|
||||
src/flt_spoe.o src/stick_table.o src/stats.o src/mux_h2.o \
|
||||
src/checks.o src/haproxy.o src/log.o src/dns.o src/peers.o \
|
||||
src/standard.o src/sample.o src/cli.o src/stream_interface.o \
|
||||
|
@ -82,19 +82,12 @@ struct cfg_postparser {
|
||||
int (*func)();
|
||||
};
|
||||
|
||||
/* some of the most common options which are also the easiest to handle */
|
||||
struct cfg_opt {
|
||||
const char *name;
|
||||
unsigned int val;
|
||||
unsigned int cap;
|
||||
unsigned int checks;
|
||||
unsigned int mode;
|
||||
};
|
||||
|
||||
extern int cfg_maxpconn;
|
||||
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);
|
||||
@ -116,12 +109,14 @@ void cfg_restore_sections(struct list *backup_sections);
|
||||
int warnif_misplaced_tcp_conn(struct proxy *proxy, const char *file, int line, const char *arg);
|
||||
int warnif_misplaced_tcp_sess(struct proxy *proxy, const char *file, int line, const char *arg);
|
||||
int warnif_misplaced_tcp_cont(struct proxy *proxy, const char *file, int line, const char *arg);
|
||||
int warnif_cond_conflicts(const struct acl_cond *cond, unsigned int where, const char *file, int line);
|
||||
int too_many_args_idx(int maxarg, int index, char **args, char **msg, int *err_code);
|
||||
int too_many_args(int maxarg, char **args, char **msg, int *err_code);
|
||||
int alertif_too_many_args_idx(int maxarg, int index, const char *file, int linenum, char **args, int *err_code);
|
||||
int alertif_too_many_args(int maxarg, const char *file, int linenum, char **args, int *err_code);
|
||||
int parse_process_number(const char *arg, unsigned long *proc, int *autoinc, char **err);
|
||||
unsigned long parse_cpu_set(const char **args, unsigned long *cpu_set, char **err);
|
||||
void free_email_alert(struct proxy *p);
|
||||
|
||||
/*
|
||||
* Sends a warning if proxy <proxy> does not have at least one of the
|
||||
|
@ -36,6 +36,9 @@ extern struct eb_root used_proxy_id; /* list of proxy IDs in use */
|
||||
extern unsigned int error_snapshot_id; /* global ID assigned to each error then incremented */
|
||||
extern struct eb_root proxy_by_name; /* tree of proxies sorted by name */
|
||||
|
||||
extern const struct cfg_opt cfg_opts[];
|
||||
extern const struct cfg_opt cfg_opts2[];
|
||||
|
||||
int start_proxies(int verbose);
|
||||
struct task *manage_proxy(struct task *t, void *context, unsigned short state);
|
||||
void soft_stop(void);
|
||||
|
@ -516,6 +516,15 @@ struct redirect_rule {
|
||||
char *cookie_str;
|
||||
};
|
||||
|
||||
/* some of the most common options which are also the easiest to handle */
|
||||
struct cfg_opt {
|
||||
const char *name;
|
||||
unsigned int val;
|
||||
unsigned int cap;
|
||||
unsigned int checks;
|
||||
unsigned int mode;
|
||||
};
|
||||
|
||||
#endif /* _TYPES_PROXY_H */
|
||||
|
||||
/*
|
||||
|
4315
src/cfgparse-listen.c
Normal file
4315
src/cfgparse-listen.c
Normal file
File diff suppressed because it is too large
Load Diff
4350
src/cfgparse.c
4350
src/cfgparse.c
File diff suppressed because it is too large
Load Diff
55
src/proxy.c
55
src/proxy.c
@ -59,6 +59,61 @@ struct eb_root used_proxy_id = EB_ROOT; /* list of proxy IDs in use */
|
||||
struct eb_root proxy_by_name = EB_ROOT; /* tree of proxies sorted by name */
|
||||
unsigned int error_snapshot_id = 0; /* global ID assigned to each error then incremented */
|
||||
|
||||
/* proxy->options */
|
||||
const struct cfg_opt cfg_opts[] =
|
||||
{
|
||||
{ "abortonclose", PR_O_ABRT_CLOSE, PR_CAP_BE, 0, 0 },
|
||||
{ "allbackups", PR_O_USE_ALL_BK, PR_CAP_BE, 0, 0 },
|
||||
{ "checkcache", PR_O_CHK_CACHE, PR_CAP_BE, 0, PR_MODE_HTTP },
|
||||
{ "clitcpka", PR_O_TCP_CLI_KA, PR_CAP_FE, 0, 0 },
|
||||
{ "contstats", PR_O_CONTSTATS, PR_CAP_FE, 0, 0 },
|
||||
{ "dontlognull", PR_O_NULLNOLOG, PR_CAP_FE, 0, 0 },
|
||||
{ "http_proxy", PR_O_HTTP_PROXY, PR_CAP_FE | PR_CAP_BE, 0, PR_MODE_HTTP },
|
||||
{ "http-buffer-request", PR_O_WREQ_BODY, PR_CAP_FE | PR_CAP_BE, 0, PR_MODE_HTTP },
|
||||
{ "http-ignore-probes", PR_O_IGNORE_PRB, PR_CAP_FE, 0, PR_MODE_HTTP },
|
||||
{ "prefer-last-server", PR_O_PREF_LAST, PR_CAP_BE, 0, PR_MODE_HTTP },
|
||||
{ "logasap", PR_O_LOGASAP, PR_CAP_FE, 0, 0 },
|
||||
{ "nolinger", PR_O_TCP_NOLING, PR_CAP_FE | PR_CAP_BE, 0, 0 },
|
||||
{ "persist", PR_O_PERSIST, PR_CAP_BE, 0, 0 },
|
||||
{ "srvtcpka", PR_O_TCP_SRV_KA, PR_CAP_BE, 0, 0 },
|
||||
#ifdef TPROXY
|
||||
{ "transparent", PR_O_TRANSP, PR_CAP_BE, 0, 0 },
|
||||
#else
|
||||
{ "transparent", 0, 0, 0, 0 },
|
||||
#endif
|
||||
|
||||
{ NULL, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
/* proxy->options2 */
|
||||
const struct cfg_opt cfg_opts2[] =
|
||||
{
|
||||
#ifdef CONFIG_HAP_LINUX_SPLICE
|
||||
{ "splice-request", PR_O2_SPLIC_REQ, PR_CAP_FE|PR_CAP_BE, 0, 0 },
|
||||
{ "splice-response", PR_O2_SPLIC_RTR, PR_CAP_FE|PR_CAP_BE, 0, 0 },
|
||||
{ "splice-auto", PR_O2_SPLIC_AUT, PR_CAP_FE|PR_CAP_BE, 0, 0 },
|
||||
#else
|
||||
{ "splice-request", 0, 0, 0, 0 },
|
||||
{ "splice-response", 0, 0, 0, 0 },
|
||||
{ "splice-auto", 0, 0, 0, 0 },
|
||||
#endif
|
||||
{ "accept-invalid-http-request", PR_O2_REQBUG_OK, PR_CAP_FE, 0, PR_MODE_HTTP },
|
||||
{ "accept-invalid-http-response", PR_O2_RSPBUG_OK, PR_CAP_BE, 0, PR_MODE_HTTP },
|
||||
{ "dontlog-normal", PR_O2_NOLOGNORM, PR_CAP_FE, 0, 0 },
|
||||
{ "log-separate-errors", PR_O2_LOGERRORS, PR_CAP_FE, 0, 0 },
|
||||
{ "log-health-checks", PR_O2_LOGHCHKS, PR_CAP_BE, 0, 0 },
|
||||
{ "socket-stats", PR_O2_SOCKSTAT, PR_CAP_FE, 0, 0 },
|
||||
{ "tcp-smart-accept", PR_O2_SMARTACC, PR_CAP_FE, 0, 0 },
|
||||
{ "tcp-smart-connect", PR_O2_SMARTCON, PR_CAP_BE, 0, 0 },
|
||||
{ "independant-streams", PR_O2_INDEPSTR, PR_CAP_FE|PR_CAP_BE, 0, 0 },
|
||||
{ "independent-streams", PR_O2_INDEPSTR, PR_CAP_FE|PR_CAP_BE, 0, 0 },
|
||||
{ "http-use-proxy-header", PR_O2_USE_PXHDR, PR_CAP_FE, 0, PR_MODE_HTTP },
|
||||
{ "http-pretend-keepalive", PR_O2_FAKE_KA, PR_CAP_BE, 0, PR_MODE_HTTP },
|
||||
{ "http-no-delay", PR_O2_NODELAY, PR_CAP_FE|PR_CAP_BE, 0, PR_MODE_HTTP },
|
||||
{ "http-use-htx", PR_O2_USE_HTX, PR_CAP_FE|PR_CAP_BE, 0, PR_MODE_HTTP },
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
* This function returns a string containing a name describing capabilities to
|
||||
* report comprehensible error messages. Specifically, it will return the words
|
||||
|
Loading…
Reference in New Issue
Block a user