[MINOR] global.maxpipes: add the ability to reserve file descriptors for pipes

This will be needed to use linux's splice() syscall.
This commit is contained in:
Willy Tarreau 2009-01-18 20:39:42 +01:00
parent a456f2a059
commit 3ec79b9c42
4 changed files with 16 additions and 1 deletions

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

View 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]);

View File

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

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