[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.
This commit is contained in:
Willy Tarreau 2009-01-25 15:42:27 +01:00
parent 65ee6be6f6
commit 43b78999ec
5 changed files with 28 additions and 71 deletions

View File

@ -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 */

View File

@ -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 <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <common/config.h>
/* 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:
*/

View File

@ -32,7 +32,6 @@
#include <types/capture.h>
#include <types/global.h>
#include <types/polling.h>
#include <proto/acl.h>
#include <proto/backend.h>
@ -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;

View File

@ -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;

View File

@ -75,7 +75,6 @@
#include <types/capture.h>
#include <types/global.h>
#include <types/polling.h>
#include <proto/acl.h>
#include <proto/backend.h>
@ -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 */