$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 #include /* works around a bug */ #include +#include #include #include @@ -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;