summaryrefslogtreecommitdiff
path: root/net/netatalk/patches/patch-ac
blob: 6f7f1bc9ea9529a89008596bdb44f6a6f3c2b046 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$NetBSD: patch-ac,v 1.5 2002/09/02 11:52:59 abs Exp $

--- etc/afpd/ofork.c.orig	Thu Feb  7 23:57:27 2002
+++ etc/afpd/ofork.c
@@ -14,6 +14,7 @@
 #include <string.h>
 #include <sys/stat.h> /* works around a bug */
 #include <sys/param.h>
+#include <sys/resource.h>
 #include <syslog.h>
 #include <errno.h>
 
@@ -146,7 +147,15 @@ struct adouble      *ad;
     int			i;
 
     if (!oforks) {
-        nforks = (getdtablesize() - 10) / 2;
+	struct rlimit rlp;
+
+	getrlimit(RLIMIT_NOFILE, &rlp);
+	if (rlp.rlim_cur < 256)
+	    rlp.rlim_cur = 256;
+	setrlimit(RLIMIT_NOFILE, &rlp);
+	getrlimit(RLIMIT_NOFILE, &rlp);
+
+        nforks = (rlp.rlim_cur - 10) / 2;
         oforks = (struct ofork **) calloc(nforks, sizeof(struct ofork *));
         if (!oforks)
             return NULL;