]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ha-inject: Move "global" variable definition to new global.c file
authorFrederic Lecaille <flecaille@haproxy.com>
Wed, 10 Dec 2025 15:06:34 +0000 (16:06 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Wed, 10 Dec 2025 16:45:28 +0000 (17:45 +0100)
Add new global.c file which is a common C file between haproxy and ha-ring.
Move <global> global struct variable definition from haproxy.c to global.c.
Add a declaration for this object to global-t.h.
Also move <stopping> from haproxy.c to global.c. Some C modules refer to
this variable. This is the case for the muxes.

Makefile
src/global.c [new file with mode: 0644]
src/haproxy.c

index 40c292821c89a494547fa16092a8b23493d7c767..4cb355d76ab2577384604894e7e87ec1bc1b8519 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -964,7 +964,7 @@ ifneq ($(EXTRA_OBJS),)
 endif
 
 OBJS_COMMON += src/mux_h2.o src/mux_h1.o src/mux_fcgi.o \
-        src/stick_table.o src/tools.o \
+        src/stick_table.o src/tools.o src/global.o \
         src/activity.o src/cli.o               \
         src/backend.o src/connection.o src/proxy.o     \
         src/cache.o src/stconn.o src/http_htx.o src/debug.o            \
diff --git a/src/global.c b/src/global.c
new file mode 100644 (file)
index 0000000..b952cf5
--- /dev/null
@@ -0,0 +1,60 @@
+#include <haproxy/global.h>
+#include <haproxy/list.h>
+#include <haproxy/protocol-t.h>
+#include <haproxy/ticks.h>
+
+/* global options */
+struct global global = {
+       .uid = -1, // not set
+       .gid = -1, // not set
+       .hard_stop_after = TICK_ETERNITY,
+       .close_spread_time = TICK_ETERNITY,
+       .close_spread_end = TICK_ETERNITY,
+       .numa_cpu_mapping = 1,
+       .nbthread = 0,
+       .req_count = 0,
+       .loggers = LIST_HEAD_INIT(global.loggers),
+       .maxzlibmem = DEFAULT_MAXZLIBMEM * 1024U * 1024U,
+       .comp_rate_lim = 0,
+       .ssl_server_verify = SSL_SERVER_VERIFY_REQUIRED,
+       .unix_bind = {
+                .ux = {
+                        .uid = -1,
+                        .gid = -1,
+                        .mode = 0,
+                }
+       },
+       .tune = {
+               .options = GTUNE_LISTENER_MQ_OPT,
+               .bufsize = (BUFSIZE + 2*sizeof(void *) - 1) & -(2*sizeof(void *)),
+               .bufsize_small = BUFSIZE_SMALL,
+               .maxrewrite = MAXREWRITE,
+               .reserved_bufs = RESERVED_BUFS,
+               .pattern_cache = DEFAULT_PAT_LRU_SIZE,
+               .pool_low_ratio  = 20,
+               .pool_high_ratio = 25,
+               .max_http_hdr = MAX_HTTP_HDR,
+#ifdef USE_OPENSSL
+               .sslcachesize = SSLCACHESIZE,
+#endif
+               .comp_maxlevel = 1,
+               .glitch_kill_maxidle = 100,
+#ifdef DEFAULT_IDLE_TIMER
+               .idle_timer = DEFAULT_IDLE_TIMER,
+#else
+               .idle_timer = 1000, /* 1 second */
+#endif
+               .nb_stk_ctr = MAX_SESS_STKCTR,
+               .default_shards = -2, /* by-group */
+       },
+#ifdef USE_OPENSSL
+#ifdef DEFAULT_MAXSSLCONN
+       .maxsslconn = DEFAULT_MAXSSLCONN,
+#endif
+#endif
+       /* by default allow clients which use a privileged port for TCP only */
+       .clt_privileged_ports = HA_PROTO_TCP,
+       /* others NULL OK */
+};
+
+int stopping;  /* non zero means stopping in progress */
index cc26c6447472c16ef304d47f73e58a7cb4825cd7..3d330efdab53450a380fec0bcefc82b83d4fab45 100644 (file)
@@ -153,63 +153,8 @@ int devnullfd = -1;
 
 static unsigned long stopping_tgroup_mask; /* Thread groups acknowledging stopping */
 
-/* global options */
-struct global global = {
-       .uid = -1, // not set
-       .gid = -1, // not set
-       .hard_stop_after = TICK_ETERNITY,
-       .close_spread_time = TICK_ETERNITY,
-       .close_spread_end = TICK_ETERNITY,
-       .numa_cpu_mapping = 1,
-       .nbthread = 0,
-       .req_count = 0,
-       .loggers = LIST_HEAD_INIT(global.loggers),
-       .maxzlibmem = DEFAULT_MAXZLIBMEM * 1024U * 1024U,
-       .comp_rate_lim = 0,
-       .ssl_server_verify = SSL_SERVER_VERIFY_REQUIRED,
-       .unix_bind = {
-                .ux = {
-                        .uid = -1,
-                        .gid = -1,
-                        .mode = 0,
-                }
-       },
-       .tune = {
-               .options = GTUNE_LISTENER_MQ_OPT,
-               .bufsize = (BUFSIZE + 2*sizeof(void *) - 1) & -(2*sizeof(void *)),
-               .bufsize_small = BUFSIZE_SMALL,
-               .maxrewrite = MAXREWRITE,
-               .reserved_bufs = RESERVED_BUFS,
-               .pattern_cache = DEFAULT_PAT_LRU_SIZE,
-               .pool_low_ratio  = 20,
-               .pool_high_ratio = 25,
-               .max_http_hdr = MAX_HTTP_HDR,
-#ifdef USE_OPENSSL
-               .sslcachesize = SSLCACHESIZE,
-#endif
-               .comp_maxlevel = 1,
-               .glitch_kill_maxidle = 100,
-#ifdef DEFAULT_IDLE_TIMER
-               .idle_timer = DEFAULT_IDLE_TIMER,
-#else
-               .idle_timer = 1000, /* 1 second */
-#endif
-               .nb_stk_ctr = MAX_SESS_STKCTR,
-               .default_shards = -2, /* by-group */
-       },
-#ifdef USE_OPENSSL
-#ifdef DEFAULT_MAXSSLCONN
-       .maxsslconn = DEFAULT_MAXSSLCONN,
-#endif
-#endif
-       /* by default allow clients which use a privileged port for TCP only */
-       .clt_privileged_ports = HA_PROTO_TCP,
-       /* others NULL OK */
-};
-
 /*********************************************************************/
 
-int stopping;  /* non zero means stopping in progress */
 int killed;    /* non zero means a hard-stop is triggered */
 int jobs = 0;   /* number of active jobs (conns, listeners, active tasks, ...) */
 int unstoppable_jobs = 0;  /* number of active jobs that can't be stopped during a soft stop */