]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] move global tuning options to the global structure
authorWilly Tarreau <w@1wt.eu>
Sun, 25 Jan 2009 14:42:27 +0000 (15:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 25 Jan 2009 14:42:27 +0000 (15:42 +0100)
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.

include/types/global.h
include/types/polling.h [deleted file]
src/cfgparse.c
src/fd.c
src/haproxy.c

index 120977906545c7514238c65d0a2fd5b67d227ab5..7862e91c695a6c43755d97ccaa656d9f0c0fcd21 100644 (file)
 #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 (file)
index e124c08..0000000
+++ /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 <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:
- */
index af72b15f292c1ba3bb391dee700014d74dcb6c9e..6defe9e9277d9fd1f14d27639b018ac4baec31ed 100644 (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;
index daa347f31d467a15895bb675e824921a2bb151a0..3d7071c9bd9ec2627254329470778a0def5a1180 100644 (file)
--- 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;
index 8ec217c19266c2b2921e2f870f37b9a370becf16..0c16e14f97b06b38b97b95fb246c8e8ac9581545 100644 (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 */