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.
This commit is contained in:
Patrick Hemmer 2023-07-27 11:09:14 -04:00 committed by Willy Tarreau
parent 997a31dbdf
commit 00e00fb424
4 changed files with 15 additions and 1 deletions

View File

@ -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,

View File

@ -0,0 +1,10 @@
#include <sys/time.h>
#include <sys/epoll.h>
#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);

View File

@ -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;

View File

@ -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) */