On Wed, Sep 28, 2016 at 03:00:20PM +0200, Paul de Weerd wrote:
> Hi,
>
> So, upgrading one of my webservers to -current (snapshot with kernel
> build #2498: Tue Sep 27 17:53:43 MDT 2016), my httpd suddenly failed
> to start. rcctl -d start httpd showed it's about hitting the open
> file limit, and trying to check the config confirmed that problem:
>
> [root@agony] # httpd -n
> httpd: proc_open: Too many open files
>
When starting the daemon, the parent opens all the possible pipe fds
between all the processes and the children close the unneeded ones
after starting up. This ramp-up quickly exceeds the default limit of
128 fds. I'm discussing an alternative approach with rzalamena@ that
will allow us to keep the default rlimit of 128 fds by opening and
passing them to the children one-after-another.
The diff below should fix it for now, we have the same in relayd.
Reyk
Index: usr.sbin/httpd/httpd.c
===================================================================
RCS file: /cvs/src/usr.sbin/httpd/httpd.c,v
retrieving revision 1.62
diff -u -p -u -p -r1.62 httpd.c
--- usr.sbin/httpd/httpd.c 28 Sep 2016 12:01:04 -0000 1.62
+++ usr.sbin/httpd/httpd.c 28 Sep 2016 13:22:39 -0000
@@ -212,6 +212,11 @@ main(int argc, char *argv[])
errx(1, "malloc failed");
}
+ if (proc_id == PROC_PARENT) {
+ /* XXX the parent opens too many fds in proc_open() */
+ socket_rlimit(-1);
+ }
+
/* only the parent returns */
proc_init(ps, procs, nitems(procs), argc0, argv, proc_id);