Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
Willy Tarreau | 8096de9 | 2010-02-26 11:12:27 +0100 | [diff] [blame] | 2 | * include/types/global.h |
| 3 | * Global variables. |
| 4 | * |
Willy Tarreau | e9f49e7 | 2012-11-11 17:42:00 +0100 | [diff] [blame] | 5 | * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu |
Willy Tarreau | 8096de9 | 2010-02-26 11:12:27 +0100 | [diff] [blame] | 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation, version 2.1 |
| 10 | * exclusively. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 21 | |
| 22 | #ifndef _TYPES_GLOBAL_H |
| 23 | #define _TYPES_GLOBAL_H |
| 24 | |
| 25 | #include <netinet/in.h> |
| 26 | |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 27 | #include <common/config.h> |
Willy Tarreau | 8071338 | 2018-11-26 10:19:54 +0100 | [diff] [blame] | 28 | #include <common/initcall.h> |
Christopher Faulet | 6adad11 | 2017-04-21 16:47:03 +0200 | [diff] [blame] | 29 | #include <common/hathreads.h> |
Willy Tarreau | 8071338 | 2018-11-26 10:19:54 +0100 | [diff] [blame] | 30 | #include <common/standard.h> |
Christopher Faulet | 6adad11 | 2017-04-21 16:47:03 +0200 | [diff] [blame] | 31 | |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 32 | #include <types/listener.h> |
Willy Tarreau | 89a6313 | 2009-08-16 17:41:45 +0200 | [diff] [blame] | 33 | #include <types/proxy.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 34 | #include <types/task.h> |
Christopher Faulet | ff2613e | 2016-11-09 11:36:17 +0100 | [diff] [blame] | 35 | #include <types/vars.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 36 | |
Emeric Brun | c8e8d12 | 2012-10-02 18:42:10 +0200 | [diff] [blame] | 37 | #ifndef UNIX_MAX_PATH |
| 38 | #define UNIX_MAX_PATH 108 |
| 39 | #endif |
| 40 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 41 | /* modes of operation (global.mode) */ |
Willy Tarreau | fbee713 | 2007-10-18 13:53:22 +0200 | [diff] [blame] | 42 | #define MODE_DEBUG 0x01 |
| 43 | #define MODE_DAEMON 0x02 |
| 44 | #define MODE_QUIET 0x04 |
| 45 | #define MODE_CHECK 0x08 |
| 46 | #define MODE_VERBOSE 0x10 |
| 47 | #define MODE_STARTING 0x20 |
| 48 | #define MODE_FOREGROUND 0x40 |
William Lallemand | 095ba4c | 2017-06-01 17:38:50 +0200 | [diff] [blame] | 49 | #define MODE_MWORKER 0x80 /* Master Worker */ |
William Lallemand | 944e619 | 2018-11-21 15:48:31 +0100 | [diff] [blame] | 50 | #define MODE_MWORKER_WAIT 0x100 /* Master Worker wait mode */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 51 | |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 52 | /* list of last checks to perform, depending on config options */ |
| 53 | #define LSTCHK_CAP_BIND 0x00000001 /* check that we can bind to any port */ |
Willy Tarreau | 29fbe51 | 2015-08-20 19:35:14 +0200 | [diff] [blame] | 54 | #define LSTCHK_NETADM 0x00000002 /* check that we have CAP_NET_ADMIN */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 55 | |
Willy Tarreau | 43b7899 | 2009-01-25 15:42:27 +0100 | [diff] [blame] | 56 | /* Global tuning options */ |
| 57 | /* available polling mechanisms */ |
| 58 | #define GTUNE_USE_SELECT (1<<0) |
| 59 | #define GTUNE_USE_POLL (1<<1) |
| 60 | #define GTUNE_USE_EPOLL (1<<2) |
| 61 | #define GTUNE_USE_KQUEUE (1<<3) |
Willy Tarreau | 3ab68cf | 2009-01-25 16:03:28 +0100 | [diff] [blame] | 62 | /* platform-specific options */ |
Willy Tarreau | e9f49e7 | 2012-11-11 17:42:00 +0100 | [diff] [blame] | 63 | #define GTUNE_USE_SPLICE (1<<4) |
Nenad Merdanovic | 88afe03 | 2014-04-14 15:56:58 +0200 | [diff] [blame] | 64 | #define GTUNE_USE_GAI (1<<5) |
Lukas Tribus | a0bcbdc | 2016-09-12 21:42:20 +0000 | [diff] [blame] | 65 | #define GTUNE_USE_REUSEPORT (1<<6) |
Willy Tarreau | 3eed10e | 2016-11-07 21:03:16 +0100 | [diff] [blame] | 66 | #define GTUNE_RESOLVE_DONTFAIL (1<<7) |
Willy Tarreau | 43b7899 | 2009-01-25 15:42:27 +0100 | [diff] [blame] | 67 | |
Olivier Houchard | 1fc0516 | 2017-04-06 01:05:05 +0200 | [diff] [blame] | 68 | #define GTUNE_SOCKET_TRANSFER (1<<8) |
William Lallemand | 4cfede8 | 2017-11-24 22:02:34 +0100 | [diff] [blame] | 69 | #define GTUNE_NOEXIT_ONFAILURE (1<<9) |
Tim Duesterhus | d6942c8 | 2017-11-20 15:58:35 +0100 | [diff] [blame] | 70 | #define GTUNE_USE_SYSTEMD (1<<10) |
Olivier Houchard | 1fc0516 | 2017-04-06 01:05:05 +0200 | [diff] [blame] | 71 | |
Willy Tarreau | beb859a | 2018-11-22 18:07:59 +0100 | [diff] [blame] | 72 | #define GTUNE_BUSY_POLLING (1<<11) |
Willy Tarreau | 7ac908b | 2019-02-27 12:02:18 +0100 | [diff] [blame] | 73 | #define GTUNE_LISTENER_MQ (1<<12) |
Willy Tarreau | 636848a | 2019-04-15 19:38:50 +0200 | [diff] [blame] | 74 | #define GTUNE_SET_DUMPABLE (1<<13) |
Willy Tarreau | beb859a | 2018-11-22 18:07:59 +0100 | [diff] [blame] | 75 | |
Willy Tarreau | 6162db2 | 2009-10-10 17:13:00 +0200 | [diff] [blame] | 76 | /* Access level for a stats socket */ |
| 77 | #define ACCESS_LVL_NONE 0 |
| 78 | #define ACCESS_LVL_USER 1 |
| 79 | #define ACCESS_LVL_OPER 2 |
| 80 | #define ACCESS_LVL_ADMIN 3 |
William Lallemand | 07a62f7 | 2017-05-24 00:57:40 +0200 | [diff] [blame] | 81 | #define ACCESS_LVL_MASK 0x3 |
| 82 | |
William Lallemand | f6975e9 | 2017-05-26 17:42:10 +0200 | [diff] [blame] | 83 | #define ACCESS_FD_LISTENERS 0x4 /* expose listeners FDs on stats socket */ |
William Lallemand | 14721be | 2018-10-26 14:47:37 +0200 | [diff] [blame] | 84 | #define ACCESS_MASTER 0x8 /* works with the master (and every other processes) */ |
| 85 | #define ACCESS_MASTER_ONLY 0x10 /* only works with the worker */ |
Willy Tarreau | 43b7899 | 2009-01-25 15:42:27 +0100 | [diff] [blame] | 86 | |
Emeric Brun | 850efd5 | 2014-01-29 12:24:34 +0100 | [diff] [blame] | 87 | /* SSL server verify mode */ |
| 88 | enum { |
| 89 | SSL_SERVER_VERIFY_NONE = 0, |
| 90 | SSL_SERVER_VERIFY_REQUIRED = 1, |
| 91 | }; |
| 92 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 93 | /* FIXME : this will have to be redefined correctly */ |
| 94 | struct global { |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 95 | int uid; |
| 96 | int gid; |
Simon Horman | 98637e5 | 2014-06-20 12:30:16 +0900 | [diff] [blame] | 97 | int external_check; |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 98 | int nbproc; |
Christopher Faulet | be0faa2 | 2017-08-29 15:37:10 +0200 | [diff] [blame] | 99 | int nbthread; |
Cyril Bonté | 203ec5a | 2017-03-23 22:44:13 +0100 | [diff] [blame] | 100 | unsigned int hard_stop_after; /* maximum time allowed to perform a soft-stop */ |
Willy Tarreau | 91886b6 | 2011-09-07 14:38:31 +0200 | [diff] [blame] | 101 | int maxconn, hardmaxconn; |
Willy Tarreau | 403edff | 2012-09-06 11:58:37 +0200 | [diff] [blame] | 102 | int maxsslconn; |
Willy Tarreau | d92aa5c | 2015-01-15 21:34:39 +0100 | [diff] [blame] | 103 | int ssl_session_max_cost; /* how many bytes an SSL session may cost */ |
| 104 | int ssl_handshake_max_cost; /* how many bytes an SSL handshake may use */ |
Willy Tarreau | fce0311 | 2015-01-15 21:32:40 +0100 | [diff] [blame] | 105 | int ssl_used_frontend; /* non-zero if SSL is used in a frontend */ |
| 106 | int ssl_used_backend; /* non-zero if SSL is used in a backend */ |
Emeric Brun | ece0c33 | 2017-12-06 13:51:49 +0100 | [diff] [blame] | 107 | int ssl_used_async_engines; /* number of used async engines */ |
Emeric Brun | 850efd5 | 2014-01-29 12:24:34 +0100 | [diff] [blame] | 108 | unsigned int ssl_server_verify; /* default verify mode on servers side */ |
Willy Tarreau | 81c25d0 | 2011-09-07 15:17:21 +0200 | [diff] [blame] | 109 | struct freq_ctr conn_per_sec; |
Willy Tarreau | 93e7c00 | 2013-10-07 18:51:07 +0200 | [diff] [blame] | 110 | struct freq_ctr sess_per_sec; |
Willy Tarreau | e43d532 | 2013-10-07 20:01:52 +0200 | [diff] [blame] | 111 | struct freq_ctr ssl_per_sec; |
Willy Tarreau | 0c9c272 | 2014-05-28 12:28:58 +0200 | [diff] [blame] | 112 | struct freq_ctr ssl_fe_keys_per_sec; |
| 113 | struct freq_ctr ssl_be_keys_per_sec; |
William Lallemand | d85f917 | 2012-11-09 17:05:39 +0100 | [diff] [blame] | 114 | struct freq_ctr comp_bps_in; /* bytes per second, before http compression */ |
| 115 | struct freq_ctr comp_bps_out; /* bytes per second, after http compression */ |
Willy Tarreau | 81c25d0 | 2011-09-07 15:17:21 +0200 | [diff] [blame] | 116 | int cps_lim, cps_max; |
Willy Tarreau | 93e7c00 | 2013-10-07 18:51:07 +0200 | [diff] [blame] | 117 | int sps_lim, sps_max; |
Willy Tarreau | e43d532 | 2013-10-07 20:01:52 +0200 | [diff] [blame] | 118 | int ssl_lim, ssl_max; |
Willy Tarreau | 0c9c272 | 2014-05-28 12:28:58 +0200 | [diff] [blame] | 119 | int ssl_fe_keys_max, ssl_be_keys_max; |
Willy Tarreau | ce3f913 | 2014-05-28 16:47:01 +0200 | [diff] [blame] | 120 | unsigned int shctx_lookups, shctx_misses; |
William Lallemand | d85f917 | 2012-11-09 17:05:39 +0100 | [diff] [blame] | 121 | int comp_rate_lim; /* HTTP compression rate limit */ |
Willy Tarreau | 3ec79b9 | 2009-01-18 20:39:42 +0100 | [diff] [blame] | 122 | int maxpipes; /* max # of pipes */ |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 123 | int maxsock; /* max # of sockets */ |
| 124 | int rlimit_nofile; /* default ulimit-n value : 0=unset */ |
Willy Tarreau | 7006045 | 2015-12-14 12:46:07 +0100 | [diff] [blame] | 125 | int rlimit_memmax_all; /* default all-process memory limit in megs ; 0=unset */ |
| 126 | int rlimit_memmax; /* default per-process memory limit in megs ; 0=unset */ |
William Lallemand | e3a7d99 | 2012-11-20 11:25:20 +0100 | [diff] [blame] | 127 | long maxzlibmem; /* max RAM for zlib in bytes */ |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 128 | int mode; |
Willy Tarreau | 1f0da24 | 2014-01-25 11:01:50 +0100 | [diff] [blame] | 129 | unsigned int req_count; /* request counter (HTTP or TCP session) for logs and unique_id */ |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 130 | int last_checks; |
Krzysztof Oledzki | b304dc7 | 2007-10-14 23:40:01 +0200 | [diff] [blame] | 131 | int spread_checks; |
Willy Tarreau | 1746eec | 2014-04-25 10:46:47 +0200 | [diff] [blame] | 132 | int max_spread_checks; |
Willy Tarreau | 18324f5 | 2014-06-27 18:10:07 +0200 | [diff] [blame] | 133 | int max_syslog_len; |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 134 | char *chroot; |
| 135 | char *pidfile; |
Krzysztof Piotr Oledzki | 48cb2ae | 2009-10-02 22:51:14 +0200 | [diff] [blame] | 136 | char *node, *desc; /* node name & description */ |
Willy Tarreau | 83061a8 | 2018-07-13 11:56:34 +0200 | [diff] [blame] | 137 | struct buffer log_tag; /* name for syslog */ |
William Lallemand | 0f99e34 | 2011-10-12 17:50:54 +0200 | [diff] [blame] | 138 | struct list logsrvs; |
Joe Williams | df5b38f | 2010-12-29 17:05:48 +0100 | [diff] [blame] | 139 | char *log_send_hostname; /* set hostname in syslog header */ |
Baptiste Assmann | 6bc8936 | 2015-08-23 09:22:25 +0200 | [diff] [blame] | 140 | char *server_state_base; /* path to a directory where server state files can be found */ |
Baptiste Assmann | e088226 | 2015-08-23 09:54:31 +0200 | [diff] [blame] | 141 | char *server_state_file; /* path to the file where server states are loaded from */ |
Willy Tarreau | 1db3771 | 2007-06-03 17:16:49 +0200 | [diff] [blame] | 142 | struct { |
| 143 | int maxpollevents; /* max number of poll events at once */ |
Willy Tarreau | a0250ba | 2008-01-06 11:22:57 +0100 | [diff] [blame] | 144 | int maxaccept; /* max number of consecutive accept() */ |
Willy Tarreau | 43b7899 | 2009-01-25 15:42:27 +0100 | [diff] [blame] | 145 | int options; /* various tuning options */ |
Olivier Houchard | 1599b80 | 2018-05-24 18:59:04 +0200 | [diff] [blame] | 146 | int runqueue_depth;/* max number of tasks to run at once */ |
Willy Tarreau | 6f4a82c | 2009-03-21 20:43:57 +0100 | [diff] [blame] | 147 | int recv_enough; /* how many input bytes at once are "enough" */ |
Willy Tarreau | 27a674e | 2009-08-17 07:23:33 +0200 | [diff] [blame] | 148 | int bufsize; /* buffer size in bytes, defaults to BUFSIZE */ |
| 149 | int maxrewrite; /* buffer max rewrite size in bytes, defaults to MAXREWRITE */ |
Willy Tarreau | a24adf0 | 2014-11-27 01:11:56 +0100 | [diff] [blame] | 150 | int reserved_bufs; /* how many buffers can only be allocated for response */ |
Willy Tarreau | 33cb065 | 2014-12-23 22:52:37 +0100 | [diff] [blame] | 151 | int buf_limit; /* if not null, how many total buffers may only be allocated */ |
Willy Tarreau | e803de2 | 2010-01-21 17:43:04 +0100 | [diff] [blame] | 152 | int client_sndbuf; /* set client sndbuf to this value if not null */ |
| 153 | int client_rcvbuf; /* set client rcvbuf to this value if not null */ |
| 154 | int server_sndbuf; /* set server sndbuf to this value if not null */ |
| 155 | int server_rcvbuf; /* set server rcvbuf to this value if not null */ |
Willy Tarreau | 43961d5 | 2010-10-04 20:39:20 +0200 | [diff] [blame] | 156 | int chksize; /* check buffer size in bytes, defaults to BUFSIZE */ |
Willy Tarreau | bd9a0a7 | 2011-10-23 21:14:29 +0200 | [diff] [blame] | 157 | int pipesize; /* pipe size in bytes, system defaults if zero */ |
Willy Tarreau | ac1932d | 2011-10-24 19:14:41 +0200 | [diff] [blame] | 158 | int max_http_hdr; /* max number of HTTP headers, use MAX_HTTP_HDR if zero */ |
Stéphane Cottin | 23e9e93 | 2017-05-18 08:58:41 +0200 | [diff] [blame] | 159 | int requri_len; /* max len of request URI, use REQURI_LEN if zero */ |
Willy Tarreau | 193b8c6 | 2012-11-22 00:17:38 +0100 | [diff] [blame] | 160 | int cookie_len; /* max length of cookie captures */ |
Willy Tarreau | f3045d2 | 2015-04-29 16:24:50 +0200 | [diff] [blame] | 161 | int pattern_cache; /* max number of entries in the pattern cache. */ |
Emeric Brun | fc32aca | 2012-09-03 12:10:29 +0200 | [diff] [blame] | 162 | int sslcachesize; /* SSL cache size in session, defaults to 20000 */ |
William Lallemand | f374783 | 2012-11-09 12:33:10 +0100 | [diff] [blame] | 163 | int comp_maxlevel; /* max HTTP compression level */ |
Olivier Houchard | 88698d9 | 2019-04-16 19:07:22 +0200 | [diff] [blame] | 164 | int pool_low_ratio; /* max ratio of FDs used before we stop using new idle connections */ |
| 165 | int pool_high_ratio; /* max ratio of FDs used before we start killing idle connections when creating new connections */ |
| 166 | int pool_low_count; /* max number of opened fd before we stop using new idle connections */ |
| 167 | int pool_high_count; /* max number of opened fd before we start killing idle connections when creating new connections */ |
Willy Tarreau | 7e31273 | 2014-02-12 16:35:14 +0100 | [diff] [blame] | 168 | unsigned short idle_timer; /* how long before an empty buffer is considered idle (ms) */ |
Willy Tarreau | 1db3771 | 2007-06-03 17:16:49 +0200 | [diff] [blame] | 169 | } tune; |
Emeric Brun | ed76092 | 2010-10-22 17:59:25 +0200 | [diff] [blame] | 170 | struct { |
| 171 | char *prefix; /* path prefix of unix bind socket */ |
| 172 | struct { /* UNIX socket permissions */ |
| 173 | uid_t uid; /* -1 to leave unchanged */ |
| 174 | gid_t gid; /* -1 to leave unchanged */ |
| 175 | mode_t mode; /* 0 to leave unchanged */ |
Emeric Brun | ed76092 | 2010-10-22 17:59:25 +0200 | [diff] [blame] | 176 | } ux; |
| 177 | } unix_bind; |
Willy Tarreau | f4571a0 | 2018-01-20 18:12:15 +0100 | [diff] [blame] | 178 | struct proxy *stats_fe; /* the frontend holding the stats settings */ |
| 179 | struct vars vars; /* list of variables for the process scope. */ |
Willy Tarreau | fc6c032 | 2012-11-16 16:12:27 +0100 | [diff] [blame] | 180 | #ifdef USE_CPU_AFFINITY |
Christopher Faulet | cb6a945 | 2017-11-22 16:50:41 +0100 | [diff] [blame] | 181 | struct { |
Willy Tarreau | ff9c914 | 2019-02-07 10:39:36 +0100 | [diff] [blame] | 182 | unsigned long proc[MAX_PROCS]; /* list of CPU masks for the 32/64 first processes */ |
| 183 | unsigned long thread[MAX_PROCS][MAX_THREADS]; /* list of CPU masks for the 32/64 first threads per process */ |
Christopher Faulet | cb6a945 | 2017-11-22 16:50:41 +0100 | [diff] [blame] | 184 | } cpu_map; |
Willy Tarreau | fc6c032 | 2012-11-16 16:12:27 +0100 | [diff] [blame] | 185 | #endif |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 186 | }; |
| 187 | |
William Lallemand | 4528611 | 2019-04-12 16:09:21 +0200 | [diff] [blame] | 188 | /* options for mworker_proc */ |
| 189 | |
| 190 | #define PROC_O_TYPE_MASTER 0x00000001 |
| 191 | #define PROC_O_TYPE_WORKER 0x00000002 |
| 192 | #define PROC_O_TYPE_PROG 0x00000004 |
| 193 | /* 0x00000008 unused */ |
| 194 | #define PROC_O_LEAVING 0x00000010 /* this process should be leaving */ |
William Lallemand | bd3de3e | 2019-04-12 16:09:22 +0200 | [diff] [blame] | 195 | /* 0x00000020 to 0x00000080 unused */ |
| 196 | #define PROC_O_START_RELOAD 0x00000100 /* Start the process even if the master was re-executed */ |
William Lallemand | 4528611 | 2019-04-12 16:09:21 +0200 | [diff] [blame] | 197 | |
William Lallemand | 7e1299b | 2018-10-26 14:47:31 +0200 | [diff] [blame] | 198 | /* |
| 199 | * Structure used to describe the processes in master worker mode |
| 200 | */ |
| 201 | struct mworker_proc { |
| 202 | int pid; |
William Lallemand | 4528611 | 2019-04-12 16:09:21 +0200 | [diff] [blame] | 203 | int options; |
William Lallemand | 9a1ee7a | 2019-04-01 11:30:02 +0200 | [diff] [blame] | 204 | char *id; |
| 205 | char **command; |
| 206 | char *path; |
William Lallemand | 7e1299b | 2018-10-26 14:47:31 +0200 | [diff] [blame] | 207 | int ipc_fd[2]; /* 0 is master side, 1 is worker side */ |
| 208 | int relative_pid; |
| 209 | int reloads; |
William Lallemand | e368330 | 2018-11-19 18:46:17 +0100 | [diff] [blame] | 210 | int timestamp; |
William Lallemand | 291810d | 2018-10-26 14:47:38 +0200 | [diff] [blame] | 211 | struct server *srv; /* the server entry in the master proxy */ |
William Lallemand | 7e1299b | 2018-10-26 14:47:31 +0200 | [diff] [blame] | 212 | struct list list; |
| 213 | }; |
| 214 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 215 | extern struct global global; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 216 | extern int pid; /* current process id */ |
Willy Tarreau | dcd4771 | 2007-11-04 23:35:08 +0100 | [diff] [blame] | 217 | extern int relative_pid; /* process id starting at 1 */ |
Willy Tarreau | 387bd4f | 2017-11-10 19:08:14 +0100 | [diff] [blame] | 218 | extern unsigned long pid_bit; /* bit corresponding to the process id */ |
Willy Tarreau | a38a717 | 2019-02-02 17:11:28 +0100 | [diff] [blame] | 219 | extern unsigned long all_proc_mask; /* mask of all processes */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 220 | extern int actconn; /* # of active sessions */ |
Willy Tarreau | af7ad00 | 2010-08-31 15:39:26 +0200 | [diff] [blame] | 221 | extern int listeners; |
Willy Tarreau | 2cc5bae | 2017-09-15 08:18:11 +0200 | [diff] [blame] | 222 | extern int jobs; /* # of active jobs (listeners, sessions, open devices) */ |
William Lallemand | a719926 | 2018-11-16 16:57:20 +0100 | [diff] [blame] | 223 | extern int unstoppable_jobs; /* # of active jobs that can't be stopped during a soft stop */ |
Willy Tarreau | 199ad24 | 2018-11-05 16:31:22 +0100 | [diff] [blame] | 224 | extern int active_peers; /* # of active peers (connection attempts and successes) */ |
Willy Tarreau | 2d372c2 | 2018-11-05 17:12:27 +0100 | [diff] [blame] | 225 | extern int connected_peers; /* # of really connected peers */ |
Willy Tarreau | 83061a8 | 2018-07-13 11:56:34 +0200 | [diff] [blame] | 226 | extern THREAD_LOCAL struct buffer trash; |
Willy Tarreau | bb545b4 | 2010-08-25 12:58:59 +0200 | [diff] [blame] | 227 | extern int nb_oldpids; /* contains the number of old pids found */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 228 | extern const int zero; |
| 229 | extern const int one; |
Alexandre Cassen | 87ea548 | 2007-10-11 20:48:58 +0200 | [diff] [blame] | 230 | extern const struct linger nolinger; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 231 | extern int stopping; /* non zero means stopping in progress */ |
Cyril Bonté | 203ec5a | 2017-03-23 22:44:13 +0100 | [diff] [blame] | 232 | extern int killed; /* non zero means a hard-stop is triggered */ |
Willy Tarreau | 3ad6a76 | 2009-08-16 10:08:02 +0200 | [diff] [blame] | 233 | extern char hostname[MAX_HOSTNAME_LEN]; |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 234 | extern char localpeer[MAX_HOSTNAME_LEN]; |
Willy Tarreau | 08ceb10 | 2011-07-24 22:58:00 +0200 | [diff] [blame] | 235 | extern struct list global_listener_queue; /* list of the temporarily limited listeners */ |
Willy Tarreau | e9b2602 | 2011-08-01 20:57:55 +0200 | [diff] [blame] | 236 | extern struct task *global_listener_queue_task; |
Willy Tarreau | ff05550 | 2014-04-28 22:27:06 +0200 | [diff] [blame] | 237 | extern unsigned int warned; /* bitfield of a few warnings to emit just once */ |
Olivier Houchard | 79321b9 | 2018-07-26 17:55:11 +0200 | [diff] [blame] | 238 | extern volatile unsigned long sleeping_thread_mask; |
William Lallemand | 6e0db2f | 2018-10-26 14:47:34 +0200 | [diff] [blame] | 239 | extern struct list proc_list; /* list of process in mworker mode */ |
William Lallemand | 16dd1b3 | 2018-11-19 18:46:18 +0100 | [diff] [blame] | 240 | extern struct mworker_proc *proc_self; /* process structure of current process */ |
William Lallemand | 4b58c80 | 2018-11-27 12:02:38 +0100 | [diff] [blame] | 241 | extern int master; /* 1 if in master, 0 otherwise */ |
Willy Tarreau | bf69640 | 2019-03-01 10:09:28 +0100 | [diff] [blame] | 242 | extern unsigned int rlim_fd_cur_at_boot; |
| 243 | extern unsigned int rlim_fd_max_at_boot; |
William Lallemand | e25473c | 2019-04-01 11:29:56 +0200 | [diff] [blame] | 244 | extern int atexit_flag; |
Willy Tarreau | ff05550 | 2014-04-28 22:27:06 +0200 | [diff] [blame] | 245 | |
| 246 | /* bit values to go with "warned" above */ |
Willy Tarreau | de9d2d7 | 2014-04-28 22:28:02 +0200 | [diff] [blame] | 247 | #define WARN_BLOCK_DEPRECATED 0x00000001 |
Willy Tarreau | 98d0485 | 2015-05-26 12:18:29 +0200 | [diff] [blame] | 248 | /* unassigned : 0x00000002 */ |
Willy Tarreau | a3c504c | 2014-04-28 22:37:32 +0200 | [diff] [blame] | 249 | #define WARN_REDISPATCH_DEPRECATED 0x00000004 |
Willy Tarreau | ed44649 | 2014-04-28 22:56:38 +0200 | [diff] [blame] | 250 | #define WARN_CLITO_DEPRECATED 0x00000008 |
| 251 | #define WARN_SRVTO_DEPRECATED 0x00000010 |
| 252 | #define WARN_CONTO_DEPRECATED 0x00000020 |
Willy Tarreau | ff05550 | 2014-04-28 22:27:06 +0200 | [diff] [blame] | 253 | |
| 254 | /* to be used with warned and WARN_* */ |
| 255 | static inline int already_warned(unsigned int warning) |
| 256 | { |
| 257 | if (warned & warning) |
| 258 | return 1; |
| 259 | warned |= warning; |
| 260 | return 0; |
| 261 | } |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 262 | |
Willy Tarreau | 2415727 | 2019-02-02 17:22:19 +0100 | [diff] [blame] | 263 | /* returns a mask if set, otherwise all_proc_mask */ |
| 264 | static inline unsigned long proc_mask(unsigned long mask) |
| 265 | { |
| 266 | return mask ? mask : all_proc_mask; |
| 267 | } |
| 268 | |
| 269 | /* returns a mask if set, otherwise all_threads_mask */ |
| 270 | static inline unsigned long thread_mask(unsigned long mask) |
| 271 | { |
| 272 | return mask ? mask : all_threads_mask; |
| 273 | } |
| 274 | |
William Lallemand | e25473c | 2019-04-01 11:29:56 +0200 | [diff] [blame] | 275 | int tell_old_pids(int sig); |
| 276 | int delete_oldpid(int pid); |
| 277 | |
Cyril Bonté | 203ec5a | 2017-03-23 22:44:13 +0100 | [diff] [blame] | 278 | void deinit(void); |
Willy Tarreau | cdb737e | 2016-12-21 18:43:10 +0100 | [diff] [blame] | 279 | void hap_register_build_opts(const char *str, int must_free); |
Willy Tarreau | e694573 | 2016-12-21 19:57:00 +0100 | [diff] [blame] | 280 | void hap_register_post_check(int (*fct)()); |
Willy Tarreau | 05554e6 | 2016-12-21 20:46:26 +0100 | [diff] [blame] | 281 | void hap_register_post_deinit(void (*fct)()); |
Willy Tarreau | cdb737e | 2016-12-21 18:43:10 +0100 | [diff] [blame] | 282 | |
Christopher Faulet | 415f611 | 2017-07-25 16:52:58 +0200 | [diff] [blame] | 283 | void hap_register_per_thread_init(int (*fct)()); |
| 284 | void hap_register_per_thread_deinit(void (*fct)()); |
| 285 | |
William Lallemand | db6bdfb | 2018-11-20 17:36:51 +0100 | [diff] [blame] | 286 | void mworker_accept_wrapper(int fd); |
William Lallemand | a57b7e3 | 2018-12-14 21:11:31 +0100 | [diff] [blame] | 287 | void mworker_reload(); |
William Lallemand | db6bdfb | 2018-11-20 17:36:51 +0100 | [diff] [blame] | 288 | |
Willy Tarreau | 8071338 | 2018-11-26 10:19:54 +0100 | [diff] [blame] | 289 | /* simplified way to declare static build options in a file */ |
| 290 | #define REGISTER_BUILD_OPTS(str) \ |
| 291 | INITCALL2(STG_REGISTER, hap_register_build_opts, (str), 0) |
| 292 | |
Willy Tarreau | 172f5ce | 2018-11-26 11:21:50 +0100 | [diff] [blame] | 293 | /* simplified way to declare a post-check callback in a file */ |
| 294 | #define REGISTER_POST_CHECK(fct) \ |
| 295 | INITCALL1(STG_REGISTER, hap_register_post_check, (fct)) |
| 296 | |
| 297 | /* simplified way to declare a post-deinit callback in a file */ |
| 298 | #define REGISTER_POST_DEINIT(fct) \ |
| 299 | INITCALL1(STG_REGISTER, hap_register_post_deinit, (fct)) |
| 300 | |
| 301 | /* simplified way to declare a per-thread init callback in a file */ |
| 302 | #define REGISTER_PER_THREAD_INIT(fct) \ |
| 303 | INITCALL1(STG_REGISTER, hap_register_per_thread_init, (fct)) |
| 304 | |
| 305 | /* simplified way to declare a per-thread deinit callback in a file */ |
| 306 | #define REGISTER_PER_THREAD_DEINIT(fct) \ |
| 307 | INITCALL1(STG_REGISTER, hap_register_per_thread_deinit, (fct)) |
| 308 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 309 | #endif /* _TYPES_GLOBAL_H */ |
| 310 | |
| 311 | /* |
| 312 | * Local variables: |
| 313 | * c-indent-level: 8 |
| 314 | * c-basic-offset: 8 |
| 315 | * End: |
| 316 | */ |