From: Willy Tarreau Date: Sun, 25 Jan 2009 14:42:27 +0000 (+0100) Subject: [MEDIUM] move global tuning options to the global structure X-Git-Tag: v1.3.16-rc1~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43b78999ec73e48b534ea0ceabde7749a8bd3c30;p=thirdparty%2Fhaproxy.git [MEDIUM] move global tuning options to the global structure The global tuning options right now only concern the polling mechanisms, and they are not in the global struct itself. It's not very practical to add other options so let's move them to the global struct and remove types/polling.h which was not used for anything else. --- diff --git a/include/types/global.h b/include/types/global.h index 1209779065..7862e91c69 100644 --- a/include/types/global.h +++ b/include/types/global.h @@ -44,6 +44,15 @@ #define LSTCHK_NETADM 0x00000004 /* check that we have CAP_NET_ADMIN */ #define LSTCHK_TCPSPLICE 0x00000008 /* check that linux tcp_splice is enabled */ +/* Global tuning options */ +/* available polling mechanisms */ +#define GTUNE_USE_SELECT (1<<0) +#define GTUNE_USE_POLL (1<<1) +#define GTUNE_USE_EPOLL (1<<2) +#define GTUNE_USE_KQUEUE (1<<3) +#define GTUNE_USE_SEPOLL (1<<4) + + /* FIXME : this will have to be redefined correctly */ struct global { int uid; @@ -65,6 +74,7 @@ struct global { struct { int maxpollevents; /* max number of poll events at once */ int maxaccept; /* max number of consecutive accept() */ + int options; /* various tuning options */ } tune; struct listener stats_sock; /* unix socket listener for statistics */ int stats_timeout; /* in ticks */ diff --git a/include/types/polling.h b/include/types/polling.h deleted file mode 100644 index e124c08dff..0000000000 --- a/include/types/polling.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - include/types/polling.h - File descriptors and polling definitions. - - Copyright (C) 2000-2007 Willy Tarreau - w@1wt.eu - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation, version 2.1 - exclusively. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _TYPES_POLLING_H -#define _TYPES_POLLING_H - -/* for fd_set */ -#include -#include -#include - -#include - -/* poll mechanisms available */ -#define POLL_USE_SELECT (1<<0) -#define POLL_USE_POLL (1<<1) -#define POLL_USE_EPOLL (1<<2) -#define POLL_USE_KQUEUE (1<<3) -#define POLL_USE_SEPOLL (1<<4) - -extern int cfg_polling_mechanism; /* POLL_USE_{SELECT|POLL|EPOLL|KQUEUE|SEPOLL} */ - - -#endif /* _TYPES_POLLING_H */ - -/* - * Local variables: - * c-indent-level: 8 - * c-basic-offset: 8 - * End: - */ diff --git a/src/cfgparse.c b/src/cfgparse.c index af72b15f29..6defe9e927 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -292,16 +291,16 @@ int cfg_parse_global(const char *file, int linenum, char **args, int inv) global.mode |= MODE_DEBUG; } else if (!strcmp(args[0], "noepoll")) { - cfg_polling_mechanism &= ~POLL_USE_EPOLL; + global.tune.options &= ~GTUNE_USE_EPOLL; } else if (!strcmp(args[0], "nosepoll")) { - cfg_polling_mechanism &= ~POLL_USE_SEPOLL; + global.tune.options &= ~GTUNE_USE_SEPOLL; } else if (!strcmp(args[0], "nokqueue")) { - cfg_polling_mechanism &= ~POLL_USE_KQUEUE; + global.tune.options &= ~GTUNE_USE_KQUEUE; } else if (!strcmp(args[0], "nopoll")) { - cfg_polling_mechanism &= ~POLL_USE_POLL; + global.tune.options &= ~GTUNE_USE_POLL; } else if (!strcmp(args[0], "quiet")) { global.mode |= MODE_QUIET; diff --git a/src/fd.c b/src/fd.c index daa347f31d..3d7071c9bd 100644 --- a/src/fd.c +++ b/src/fd.c @@ -25,8 +25,6 @@ int maxfd; /* # of the highest fd + 1 */ int totalconn; /* total # of terminated sessions */ int actconn; /* # of active sessions */ -int cfg_polling_mechanism = 0; /* POLL_USE_{SELECT|POLL|EPOLL} */ - struct poller pollers[MAX_POLLERS]; struct poller cur_poller; int nbpollers = 0; diff --git a/src/haproxy.c b/src/haproxy.c index 8ec217c192..0c16e14f97 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -75,7 +75,6 @@ #include #include -#include #include #include @@ -409,18 +408,18 @@ void init(int argc, char **argv) init_pendconn(); init_proto_http(); - cfg_polling_mechanism = POLL_USE_SELECT; /* select() is always available */ + global.tune.options |= GTUNE_USE_SELECT; /* select() is always available */ #if defined(ENABLE_POLL) - cfg_polling_mechanism |= POLL_USE_POLL; + global.tune.options |= GTUNE_USE_POLL; #endif #if defined(ENABLE_EPOLL) - cfg_polling_mechanism |= POLL_USE_EPOLL; + global.tune.options |= GTUNE_USE_EPOLL; #endif #if defined(ENABLE_SEPOLL) - cfg_polling_mechanism |= POLL_USE_SEPOLL; + global.tune.options |= GTUNE_USE_SEPOLL; #endif #if defined(ENABLE_KQUEUE) - cfg_polling_mechanism |= POLL_USE_KQUEUE; + global.tune.options |= GTUNE_USE_KQUEUE; #endif pid = getpid(); @@ -444,19 +443,19 @@ void init(int argc, char **argv) } #if defined(ENABLE_EPOLL) else if (*flag == 'd' && flag[1] == 'e') - cfg_polling_mechanism &= ~POLL_USE_EPOLL; + global.tune.options &= ~GTUNE_USE_EPOLL; #endif #if defined(ENABLE_SEPOLL) else if (*flag == 'd' && flag[1] == 's') - cfg_polling_mechanism &= ~POLL_USE_SEPOLL; + global.tune.options &= ~GTUNE_USE_SEPOLL; #endif #if defined(ENABLE_POLL) else if (*flag == 'd' && flag[1] == 'p') - cfg_polling_mechanism &= ~POLL_USE_POLL; + global.tune.options &= ~GTUNE_USE_POLL; #endif #if defined(ENABLE_KQUEUE) else if (*flag == 'd' && flag[1] == 'k') - cfg_polling_mechanism &= ~POLL_USE_KQUEUE; + global.tune.options &= ~GTUNE_USE_KQUEUE; #endif else if (*flag == 'V') arg_mode |= MODE_VERBOSE; @@ -615,19 +614,19 @@ void init(int argc, char **argv) * Built-in pollers have been registered before main(). */ - if (!(cfg_polling_mechanism & POLL_USE_KQUEUE)) + if (!(global.tune.options & GTUNE_USE_KQUEUE)) disable_poller("kqueue"); - if (!(cfg_polling_mechanism & POLL_USE_EPOLL)) + if (!(global.tune.options & GTUNE_USE_EPOLL)) disable_poller("epoll"); - if (!(cfg_polling_mechanism & POLL_USE_SEPOLL)) + if (!(global.tune.options & GTUNE_USE_SEPOLL)) disable_poller("sepoll"); - if (!(cfg_polling_mechanism & POLL_USE_POLL)) + if (!(global.tune.options & GTUNE_USE_POLL)) disable_poller("poll"); - if (!(cfg_polling_mechanism & POLL_USE_SELECT)) + if (!(global.tune.options & GTUNE_USE_SELECT)) disable_poller("select"); /* Note: we could disable any poller by name here */