Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
| 2 | include/types/global.h |
| 3 | Global variables. |
| 4 | |
Willy Tarreau | 92fb983 | 2007-10-16 17:34:28 +0200 | [diff] [blame] | 5 | Copyright (C) 2000-2007 Willy Tarreau - w@1wt.eu |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [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 | */ |
| 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 | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 30 | #include <types/task.h> |
| 31 | |
| 32 | /* modes of operation (global.mode) */ |
Willy Tarreau | fbee713 | 2007-10-18 13:53:22 +0200 | [diff] [blame] | 33 | #define MODE_DEBUG 0x01 |
| 34 | #define MODE_DAEMON 0x02 |
| 35 | #define MODE_QUIET 0x04 |
| 36 | #define MODE_CHECK 0x08 |
| 37 | #define MODE_VERBOSE 0x10 |
| 38 | #define MODE_STARTING 0x20 |
| 39 | #define MODE_FOREGROUND 0x40 |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 40 | |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 41 | /* list of last checks to perform, depending on config options */ |
| 42 | #define LSTCHK_CAP_BIND 0x00000001 /* check that we can bind to any port */ |
| 43 | #define LSTCHK_CTTPROXY 0x00000002 /* check that tproxy is enabled */ |
| 44 | #define LSTCHK_NETADM 0x00000004 /* check that we have CAP_NET_ADMIN */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 45 | |
Willy Tarreau | 43b7899 | 2009-01-25 15:42:27 +0100 | [diff] [blame] | 46 | /* Global tuning options */ |
| 47 | /* available polling mechanisms */ |
| 48 | #define GTUNE_USE_SELECT (1<<0) |
| 49 | #define GTUNE_USE_POLL (1<<1) |
| 50 | #define GTUNE_USE_EPOLL (1<<2) |
| 51 | #define GTUNE_USE_KQUEUE (1<<3) |
| 52 | #define GTUNE_USE_SEPOLL (1<<4) |
Willy Tarreau | 3ab68cf | 2009-01-25 16:03:28 +0100 | [diff] [blame] | 53 | /* platform-specific options */ |
| 54 | #define GTUNE_USE_SPLICE (1<<5) |
Willy Tarreau | 43b7899 | 2009-01-25 15:42:27 +0100 | [diff] [blame] | 55 | |
| 56 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 57 | /* FIXME : this will have to be redefined correctly */ |
| 58 | struct global { |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 59 | int uid; |
| 60 | int gid; |
| 61 | int nbproc; |
| 62 | int maxconn; |
Willy Tarreau | 3ec79b9 | 2009-01-18 20:39:42 +0100 | [diff] [blame] | 63 | int maxpipes; /* max # of pipes */ |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 64 | int maxsock; /* max # of sockets */ |
| 65 | int rlimit_nofile; /* default ulimit-n value : 0=unset */ |
| 66 | int rlimit_memmax; /* default ulimit-d in megs value : 0=unset */ |
| 67 | int mode; |
| 68 | int last_checks; |
Krzysztof Oledzki | b304dc7 | 2007-10-14 23:40:01 +0200 | [diff] [blame] | 69 | int spread_checks; |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 70 | char *chroot; |
| 71 | char *pidfile; |
| 72 | int logfac1, logfac2; |
| 73 | int loglev1, loglev2; |
Willy Tarreau | f7edefa | 2009-05-10 17:20:05 +0200 | [diff] [blame] | 74 | int minlvl1, minlvl2; |
Robert Tsai | 81ae195 | 2007-12-05 10:47:29 +0100 | [diff] [blame] | 75 | struct logsrv logsrv1, logsrv2; |
Willy Tarreau | 1db3771 | 2007-06-03 17:16:49 +0200 | [diff] [blame] | 76 | struct { |
| 77 | int maxpollevents; /* max number of poll events at once */ |
Willy Tarreau | a0250ba | 2008-01-06 11:22:57 +0100 | [diff] [blame] | 78 | int maxaccept; /* max number of consecutive accept() */ |
Willy Tarreau | 43b7899 | 2009-01-25 15:42:27 +0100 | [diff] [blame] | 79 | int options; /* various tuning options */ |
Willy Tarreau | 6f4a82c | 2009-03-21 20:43:57 +0100 | [diff] [blame] | 80 | int recv_enough; /* how many input bytes at once are "enough" */ |
Willy Tarreau | 1db3771 | 2007-06-03 17:16:49 +0200 | [diff] [blame] | 81 | } tune; |
Willy Tarreau | 92fb983 | 2007-10-16 17:34:28 +0200 | [diff] [blame] | 82 | struct listener stats_sock; /* unix socket listener for statistics */ |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 83 | int stats_timeout; /* in ticks */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | extern struct global global; |
| 87 | extern char *progname; /* program name */ |
| 88 | extern int pid; /* current process id */ |
Willy Tarreau | dcd4771 | 2007-11-04 23:35:08 +0100 | [diff] [blame] | 89 | extern int relative_pid; /* process id starting at 1 */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 90 | extern int actconn; /* # of active sessions */ |
| 91 | extern int listeners; |
| 92 | extern char trash[BUFSIZE]; |
| 93 | extern const int zero; |
| 94 | extern const int one; |
Alexandre Cassen | 87ea548 | 2007-10-11 20:48:58 +0200 | [diff] [blame] | 95 | extern const struct linger nolinger; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 96 | extern int stopping; /* non zero means stopping in progress */ |
Willy Tarreau | 3ad6a76 | 2009-08-16 10:08:02 +0200 | [diff] [blame] | 97 | extern char hostname[MAX_HOSTNAME_LEN]; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 98 | |
| 99 | #endif /* _TYPES_GLOBAL_H */ |
| 100 | |
| 101 | /* |
| 102 | * Local variables: |
| 103 | * c-indent-level: 8 |
| 104 | * c-basic-offset: 8 |
| 105 | * End: |
| 106 | */ |