[MINOR] global.maxpipes: add the ability to reserve file descriptors for pipes
This will be needed to use linux's splice() syscall.
diff --git a/include/types/global.h b/include/types/global.h
index 38b194c..8c28930 100644
--- a/include/types/global.h
+++ b/include/types/global.h
@@ -50,6 +50,7 @@
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 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 d41edf7..caf259b 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -399,6 +399,17 @@
}
#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 0ee6a72..c0fb712 100644
--- a/src/fd.c
+++ b/src/fd.c
@@ -26,6 +26,7 @@
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 48b76ba..d6c18f9 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -393,7 +393,7 @@
* 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 @@
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;