]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] global.maxpipes: add the ability to reserve file descriptors for pipes
authorWilly Tarreau <w@1wt.eu>
Sun, 18 Jan 2009 19:39:42 +0000 (20:39 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 18 Jan 2009 19:39:42 +0000 (20:39 +0100)
This will be needed to use linux's splice() syscall.

include/types/global.h
src/cfgparse.c
src/fd.c
src/haproxy.c

index 38b194c2d7b124b1e7adfef33784227e3e477a42..8c2893095c0c5f655ea9287ba0fa5056d9db893c 100644 (file)
@@ -50,6 +50,7 @@ struct global {
        int gid;
        int nbproc;
        int maxconn;
+       int maxpipes;           /* max # of pipes */
        int maxsock;            /* max # of sockets */
        int rlimit_nofile;      /* default ulimit-n value : 0=unset */
        int rlimit_memmax;      /* default ulimit-d in megs value : 0=unset */
@@ -74,6 +75,7 @@ extern char *progname;          /* program name */
 extern int  pid;                /* current process id */
 extern int  relative_pid;       /* process id starting at 1 */
 extern int  actconn;            /* # of active sessions */
+extern int  usedpipes;          /* # of used pipes */
 extern int listeners;
 extern char trash[BUFSIZE];
 extern const int zero;
index d41edf7d86fd5f732fd9d779f69a89afebdf211f..caf259ba37e0554dc1096078e6f1e228cef4d114 100644 (file)
@@ -399,6 +399,17 @@ int cfg_parse_global(const char *file, int linenum, char **args, int inv)
                }
 #endif /* SYSTEM_MAXCONN */
        }
+       else if (!strcmp(args[0], "maxpipes")) {
+               if (global.maxpipes != 0) {
+                       Alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]);
+                       return 0;
+               }
+               if (*(args[1]) == 0) {
+                       Alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);
+                       return -1;
+               }
+               global.maxpipes = atol(args[1]);
+       }
        else if (!strcmp(args[0], "ulimit-n")) {
                if (global.rlimit_nofile != 0) {
                        Alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]);
index 0ee6a723edafb3fa35011117f2f05677b34ec98f..c0fb71287872ea49f620c3e46e9daed1904dd4ac 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -26,6 +26,7 @@ struct fdtab *fdtab = NULL;     /* array of all the file descriptors */
 int maxfd;                      /* # of the highest fd + 1 */
 int totalconn;                  /* total # of terminated sessions */
 int actconn;                    /* # of active sessions */
+int usedpipes;                  /* # of pipes in use (2 fds each) */
 
 int cfg_polling_mechanism = 0;  /* POLL_USE_{SELECT|POLL|EPOLL} */
 
index 48b76ba672bbe8e377c3451dd7e480cac4d72d1c..d6c18f951ed75cd2fcc78cbc32bb91d7d25f26e5 100644 (file)
@@ -393,7 +393,7 @@ void init(int argc, char **argv)
         * Initialize the previously static variables.
         */
     
-       totalconn = actconn = maxfd = listeners = stopping = 0;
+       usedpipes = totalconn = actconn = maxfd = listeners = stopping = 0;
     
 
 #ifdef HAPROXY_MEMMAX
@@ -549,6 +549,7 @@ void init(int argc, char **argv)
                global.maxconn = DEFAULT_MAXCONN;
 
        global.maxsock += global.maxconn * 2; /* each connection needs two sockets */
+       global.maxsock += global.maxpipes * 2; /* each pipe needs two FDs */
 
        if (global.tune.maxpollevents <= 0)
                global.tune.maxpollevents = MAX_POLL_EVENTS;