diff --git a/include/types/global.h b/include/types/global.h index 38b194c2d..8c2893095 100644 --- a/include/types/global.h +++ b/include/types/global.h @@ -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; diff --git a/src/cfgparse.c b/src/cfgparse.c index d41edf7d8..caf259ba3 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -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]); diff --git a/src/fd.c b/src/fd.c index 0ee6a723e..c0fb71287 100644 --- 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} */ diff --git a/src/haproxy.c b/src/haproxy.c index 48b76ba67..d6c18f951 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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;