From: Patrick Hemmer Date: Thu, 27 Jul 2023 15:09:14 +0000 (-0400) Subject: REORG: cfgparse: extract curproxy as a global variable X-Git-Tag: v2.9-dev3~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=00e00fb42;p=thirdparty%2Fhaproxy.git REORG: cfgparse: extract curproxy as a global variable This extracts curproxy from cfg_parse_listen so that it can be referenced by keywords that need the context of the proxy they are being used within. --- diff --git a/include/haproxy/cfgparse.h b/include/haproxy/cfgparse.h index 3896b57ec7..20d72972d8 100644 --- a/include/haproxy/cfgparse.h +++ b/include/haproxy/cfgparse.h @@ -97,6 +97,8 @@ extern struct cfg_kw_list cfg_keywords; extern char *cursection; extern int non_global_section_parsed; +extern struct proxy *curproxy; + 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); int cfg_parse_track_sc_num(unsigned int *track_sc_num, diff --git a/include/haproxy/timeshift.h b/include/haproxy/timeshift.h new file mode 100644 index 0000000000..62e58550f6 --- /dev/null +++ b/include/haproxy/timeshift.h @@ -0,0 +1,10 @@ +#include +#include + +#define gettimeofday(tv, tz) timeshift_gettimeofday(tv, tz) +#define clock_gettime(clk_id, tp) timeshift_clock_gettime(clk_id, tp) +#define epoll_wait(epfd, events, maxevents, timeout) timeshift_epoll_wait(epfd, events, maxevents, timeout) + +int timeshift_gettimeofday(struct timeval *tv, void *tz); +int timeshift_clock_gettime(clockid_t clk_id, struct timespec *tp); +int timeshift_epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout); diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index 3864a11c89..292f1626e4 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -201,7 +201,6 @@ int warnif_misplaced_tcp_conn(struct proxy *proxy, const char *file, int line, c int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) { - static struct proxy *curproxy = NULL; static struct proxy *curr_defproxy = NULL; static struct proxy *last_defproxy = NULL; const char *err; diff --git a/src/cfgparse.c b/src/cfgparse.c index d5422f2c5e..2948a51fa1 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -101,6 +101,9 @@ struct list postparsers = LIST_HEAD_INIT(postparsers); extern struct proxy *mworker_proxy; +/* curproxy is only valid during parsing and will be NULL afterwards. */ +struct proxy *curproxy; + char *cursection = NULL; int cfg_maxpconn = 0; /* # of simultaneous connections per proxy (-N) */ int cfg_maxconn = 0; /* # of simultaneous connections, (-n) */