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 | * |
| 5 | * Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu |
| 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> |
Robert Tsai | 81ae195 | 2007-12-05 10:47:29 +0100 | [diff] [blame] | 28 | #include <types/log.h> |
Willy Tarreau | 92fb983 | 2007-10-16 17:34:28 +0200 | [diff] [blame] | 29 | #include <types/protocols.h> |
Willy Tarreau | 89a6313 | 2009-08-16 17:41:45 +0200 | [diff] [blame] | 30 | #include <types/proxy.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 31 | #include <types/task.h> |
| 32 | |
| 33 | /* modes of operation (global.mode) */ |
Willy Tarreau | fbee713 | 2007-10-18 13:53:22 +0200 | [diff] [blame] | 34 | #define MODE_DEBUG 0x01 |
| 35 | #define MODE_DAEMON 0x02 |
| 36 | #define MODE_QUIET 0x04 |
| 37 | #define MODE_CHECK 0x08 |
| 38 | #define MODE_VERBOSE 0x10 |
| 39 | #define MODE_STARTING 0x20 |
| 40 | #define MODE_FOREGROUND 0x40 |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 41 | |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 42 | /* list of last checks to perform, depending on config options */ |
| 43 | #define LSTCHK_CAP_BIND 0x00000001 /* check that we can bind to any port */ |
| 44 | #define LSTCHK_CTTPROXY 0x00000002 /* check that tproxy is enabled */ |
| 45 | #define LSTCHK_NETADM 0x00000004 /* check that we have CAP_NET_ADMIN */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 46 | |
Willy Tarreau | 43b7899 | 2009-01-25 15:42:27 +0100 | [diff] [blame] | 47 | /* Global tuning options */ |
| 48 | /* available polling mechanisms */ |
| 49 | #define GTUNE_USE_SELECT (1<<0) |
| 50 | #define GTUNE_USE_POLL (1<<1) |
| 51 | #define GTUNE_USE_EPOLL (1<<2) |
| 52 | #define GTUNE_USE_KQUEUE (1<<3) |
| 53 | #define GTUNE_USE_SEPOLL (1<<4) |
Willy Tarreau | 3ab68cf | 2009-01-25 16:03:28 +0100 | [diff] [blame] | 54 | /* platform-specific options */ |
| 55 | #define GTUNE_USE_SPLICE (1<<5) |
Willy Tarreau | 43b7899 | 2009-01-25 15:42:27 +0100 | [diff] [blame] | 56 | |
Willy Tarreau | 6162db2 | 2009-10-10 17:13:00 +0200 | [diff] [blame] | 57 | /* Access level for a stats socket */ |
| 58 | #define ACCESS_LVL_NONE 0 |
| 59 | #define ACCESS_LVL_USER 1 |
| 60 | #define ACCESS_LVL_OPER 2 |
| 61 | #define ACCESS_LVL_ADMIN 3 |
Willy Tarreau | 43b7899 | 2009-01-25 15:42:27 +0100 | [diff] [blame] | 62 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 63 | /* FIXME : this will have to be redefined correctly */ |
| 64 | struct global { |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 65 | int uid; |
| 66 | int gid; |
| 67 | int nbproc; |
Willy Tarreau | 91886b6 | 2011-09-07 14:38:31 +0200 | [diff] [blame] | 68 | int maxconn, hardmaxconn; |
Willy Tarreau | 81c25d0 | 2011-09-07 15:17:21 +0200 | [diff] [blame] | 69 | struct freq_ctr conn_per_sec; |
| 70 | int cps_lim, cps_max; |
Willy Tarreau | 3ec79b9 | 2009-01-18 20:39:42 +0100 | [diff] [blame] | 71 | int maxpipes; /* max # of pipes */ |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 72 | int maxsock; /* max # of sockets */ |
| 73 | int rlimit_nofile; /* default ulimit-n value : 0=unset */ |
| 74 | int rlimit_memmax; /* default ulimit-d in megs value : 0=unset */ |
| 75 | int mode; |
William Lallemand | 5f23240 | 2012-04-05 18:02:55 +0200 | [diff] [blame] | 76 | unsigned int req_count; /* HTTP request counter */ |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 77 | int last_checks; |
Krzysztof Oledzki | b304dc7 | 2007-10-14 23:40:01 +0200 | [diff] [blame] | 78 | int spread_checks; |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 79 | char *chroot; |
| 80 | char *pidfile; |
Krzysztof Piotr Oledzki | 48cb2ae | 2009-10-02 22:51:14 +0200 | [diff] [blame] | 81 | char *node, *desc; /* node name & description */ |
Kevinm | 48936af | 2010-12-22 16:08:21 +0000 | [diff] [blame] | 82 | char *log_tag; /* name for syslog */ |
William Lallemand | 0f99e34 | 2011-10-12 17:50:54 +0200 | [diff] [blame] | 83 | struct list logsrvs; |
Joe Williams | df5b38f | 2010-12-29 17:05:48 +0100 | [diff] [blame] | 84 | char *log_send_hostname; /* set hostname in syslog header */ |
Willy Tarreau | 1db3771 | 2007-06-03 17:16:49 +0200 | [diff] [blame] | 85 | struct { |
| 86 | int maxpollevents; /* max number of poll events at once */ |
Willy Tarreau | a0250ba | 2008-01-06 11:22:57 +0100 | [diff] [blame] | 87 | int maxaccept; /* max number of consecutive accept() */ |
Willy Tarreau | 43b7899 | 2009-01-25 15:42:27 +0100 | [diff] [blame] | 88 | int options; /* various tuning options */ |
Willy Tarreau | 6f4a82c | 2009-03-21 20:43:57 +0100 | [diff] [blame] | 89 | int recv_enough; /* how many input bytes at once are "enough" */ |
Willy Tarreau | 27a674e | 2009-08-17 07:23:33 +0200 | [diff] [blame] | 90 | int bufsize; /* buffer size in bytes, defaults to BUFSIZE */ |
| 91 | int maxrewrite; /* buffer max rewrite size in bytes, defaults to MAXREWRITE */ |
Willy Tarreau | e803de2 | 2010-01-21 17:43:04 +0100 | [diff] [blame] | 92 | int client_sndbuf; /* set client sndbuf to this value if not null */ |
| 93 | int client_rcvbuf; /* set client rcvbuf to this value if not null */ |
| 94 | int server_sndbuf; /* set server sndbuf to this value if not null */ |
| 95 | int server_rcvbuf; /* set server rcvbuf to this value if not null */ |
Willy Tarreau | 43961d5 | 2010-10-04 20:39:20 +0200 | [diff] [blame] | 96 | int chksize; /* check buffer size in bytes, defaults to BUFSIZE */ |
Willy Tarreau | bd9a0a7 | 2011-10-23 21:14:29 +0200 | [diff] [blame] | 97 | int pipesize; /* pipe size in bytes, system defaults if zero */ |
Willy Tarreau | ac1932d | 2011-10-24 19:14:41 +0200 | [diff] [blame] | 98 | int max_http_hdr; /* max number of HTTP headers, use MAX_HTTP_HDR if zero */ |
Willy Tarreau | 1db3771 | 2007-06-03 17:16:49 +0200 | [diff] [blame] | 99 | } tune; |
Emeric Brun | ed76092 | 2010-10-22 17:59:25 +0200 | [diff] [blame] | 100 | struct { |
| 101 | char *prefix; /* path prefix of unix bind socket */ |
| 102 | struct { /* UNIX socket permissions */ |
| 103 | uid_t uid; /* -1 to leave unchanged */ |
| 104 | gid_t gid; /* -1 to leave unchanged */ |
| 105 | mode_t mode; /* 0 to leave unchanged */ |
| 106 | int level; /* access level (ACCESS_LVL_*) */ |
| 107 | } ux; |
| 108 | } unix_bind; |
Willy Tarreau | 92fb983 | 2007-10-16 17:34:28 +0200 | [diff] [blame] | 109 | struct listener stats_sock; /* unix socket listener for statistics */ |
Willy Tarreau | 89a6313 | 2009-08-16 17:41:45 +0200 | [diff] [blame] | 110 | struct proxy *stats_fe; /* the frontend holding the stats settings */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | extern struct global global; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 114 | extern int pid; /* current process id */ |
Willy Tarreau | dcd4771 | 2007-11-04 23:35:08 +0100 | [diff] [blame] | 115 | extern int relative_pid; /* process id starting at 1 */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 116 | extern int actconn; /* # of active sessions */ |
Willy Tarreau | af7ad00 | 2010-08-31 15:39:26 +0200 | [diff] [blame] | 117 | extern int listeners; |
| 118 | extern int jobs; /* # of active jobs */ |
David du Colombier | 7af4605 | 2012-05-16 14:16:48 +0200 | [diff] [blame] | 119 | extern char *trash; |
| 120 | extern int trashlen; |
Willy Tarreau | 8096de9 | 2010-02-26 11:12:27 +0100 | [diff] [blame] | 121 | extern char *swap_buffer; |
Willy Tarreau | bb545b4 | 2010-08-25 12:58:59 +0200 | [diff] [blame] | 122 | extern int nb_oldpids; /* contains the number of old pids found */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 123 | extern const int zero; |
| 124 | extern const int one; |
Alexandre Cassen | 87ea548 | 2007-10-11 20:48:58 +0200 | [diff] [blame] | 125 | extern const struct linger nolinger; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 126 | extern int stopping; /* non zero means stopping in progress */ |
Willy Tarreau | 3ad6a76 | 2009-08-16 10:08:02 +0200 | [diff] [blame] | 127 | extern char hostname[MAX_HOSTNAME_LEN]; |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 128 | extern char localpeer[MAX_HOSTNAME_LEN]; |
Willy Tarreau | 08ceb10 | 2011-07-24 22:58:00 +0200 | [diff] [blame] | 129 | extern struct list global_listener_queue; /* list of the temporarily limited listeners */ |
Willy Tarreau | e9b2602 | 2011-08-01 20:57:55 +0200 | [diff] [blame] | 130 | extern struct task *global_listener_queue_task; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 131 | |
| 132 | #endif /* _TYPES_GLOBAL_H */ |
| 133 | |
| 134 | /* |
| 135 | * Local variables: |
| 136 | * c-indent-level: 8 |
| 137 | * c-basic-offset: 8 |
| 138 | * End: |
| 139 | */ |