blob: b93210cf76067b41197902d5704e7ea8d9bc884a (
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.4 2002/09/02 11:43:39 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 < 128)
+ rlp.rlim_cur = 128;
+ 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;
|