]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: cfgparse: extract curproxy as a global variable
authorPatrick Hemmer <patrick.hemmer@gmail.com>
Thu, 27 Jul 2023 15:09:14 +0000 (11:09 -0400)
committerWilly Tarreau <w@1wt.eu>
Tue, 1 Aug 2023 08:48:28 +0000 (10:48 +0200)
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.

include/haproxy/cfgparse.h
include/haproxy/timeshift.h [new file with mode: 0644]
src/cfgparse-listen.c
src/cfgparse.c

index 3896b57ec7f35fdee397f87288c5539203598b02..20d72972d8982fcbc62967677d3203e0cfa67ff0 100644 (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,
diff --git a/include/haproxy/timeshift.h b/include/haproxy/timeshift.h
new file mode 100644 (file)
index 0000000..62e5855
--- /dev/null
@@ -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);
index 3864a11c8986c586240d4fc95465cd093385be32..292f1626e4dfac225a78c7625d93a7f5a7207d7d 100644 (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;
index d5422f2c5e72a3c6fb13074b4c75ea2758352c49..2948a51fa1f20e22a4ddcfbe87adf89f3c8ef1cf 100644 (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) */