summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/hoststated/relay.c16
-rw-r--r--usr.sbin/relayd/relay.c16
2 files changed, 30 insertions, 2 deletions
diff --git a/usr.sbin/hoststated/relay.c b/usr.sbin/hoststated/relay.c
index 781ed715e9b..8039aec31ab 100644
--- a/usr.sbin/hoststated/relay.c
+++ b/usr.sbin/hoststated/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) &&
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) &&