diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-11-28 16:25:13 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-11-28 16:25:13 +0000 |
commit | 918449653e5e0fcd61546ce050b00c55e5ce3c34 (patch) | |
tree | 160d9f00e29cd3078d1953678a414fcc003e998f /usr.sbin/relayd | |
parent | 4a53432ddcbfc0af62fa1fe6f19aa19251e3991b (diff) |
bump the current file descriptor resource limit (openfiles-cur) to the
maximum number of file descriptors for this login class
(openfiles-max) of the relay child processes. this will allow 1024
instead of just 128 open file descriptors in the default configuration
(class daemon), use the openfiles-max capability and the sysctl
kern.maxfiles to adjust the value.
ok gilles@ pyr@
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r-- | usr.sbin/relayd/relay.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index 781ed715e9b..8039aec31ab 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.73 2007/11/28 14:41:36 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.74 2007/11/28 16:25:12 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -24,6 +24,7 @@ #include <sys/un.h> #include <sys/tree.h> #include <sys/hash.h> +#include <sys/resource.h> #include <net/if.h> #include <netinet/in_systm.h> @@ -450,6 +451,19 @@ relay_init(void) struct relay *rlay; struct host *host; struct timeval tv; + struct rlimit rl; + + if (getrlimit(RLIMIT_NOFILE, &rl) == -1) + fatal("relay_init: failed to get resource limit"); + log_debug("relay_init: max open files %d", rl.rlim_max); + + /* + * Allow the maximum number of open file descriptors for this + * login class (which should be the class "daemon" by default). + */ + rl.rlim_cur = rl.rlim_max; + if (setrlimit(RLIMIT_NOFILE, &rl) == -1) + fatal("relay_init: failed to set resource limit"); TAILQ_FOREACH(rlay, env->relays, entry) { if ((rlay->conf.flags & F_SSL) && |