From: Frederic Lecaille Date: Wed, 10 Dec 2025 15:06:34 +0000 (+0100) Subject: MINOR: ha-inject: Move "global" variable definition to new global.c file X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=decb9e04d23adb18576a62f34b4073e382f899b7;p=thirdparty%2Fhaproxy.git MINOR: ha-inject: Move "global" variable definition to new global.c file Add new global.c file which is a common C file between haproxy and ha-ring. Move global struct variable definition from haproxy.c to global.c. Add a declaration for this object to global-t.h. Also move from haproxy.c to global.c. Some C modules refer to this variable. This is the case for the muxes. --- diff --git a/Makefile b/Makefile index 40c292821..4cb355d76 100644 --- 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 index 000000000..b952cf56a --- /dev/null +++ b/src/global.c @@ -0,0 +1,60 @@ +#include +#include +#include +#include + +/* 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 */ diff --git a/src/haproxy.c b/src/haproxy.c index cc26c6447..3d330efda 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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 */