commit e1e64ac
Merge pull request 'Log xs_socket_accept failure reason and document OpenBSD login class w/ extended openfiles' (#559) from oxzi/snac2:openbsd-openfiles-nfiles into master Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/559
3 files changed,
+45,
-2
+35,
-0
1@@ -704,6 +704,41 @@ out there. If you want your language file to be included in the standard
2 .Nm
3 distribution, please send me a link to it via the Fediverse to @grunfink@comam.es
4 or make a PR via the Git repository.
5+.Ss Number of open files on OpenBSD and login classes
6+Being a file intensive application, even a small
7+.Nm
8+instance might open lots of files, especially when forwarding a new post to
9+other instances.
10+.Pp
11+OpenBSD's daemon login class comes with a very low
12+.Pa openfiles
13+value, usually restricting the amount of open files to 128 (cur), 1024 (max).
14+This can result in
15+.Nm
16+to stop working due to too many open files.
17+.Pp
18+To continue operation, a new
19+.Pa snac
20+login class can be created. Please consult
21+.Xr login.conf 5
22+and afterwards create a new login class as follows.
23+.Bd -literal -offset indent
24+snac:\\
25+ :openfiles=4096:\\
26+ :tc=daemon:
27+.Ed
28+.Pp
29+After rebuilding the
30+.Pa /etc/login.conf.db ,
31+ensure that your snac user's login class is set to
32+.Pa snac :
33+.Bd -literal -offset indent
34+# cap_mkdb /etc/login.conf
35+# usermod -L snac SNACUSER
36+.Ed
37+.Pp
38+One restart later, the daemon should run with increased
39+.Pa openfiles .
40 .Sh ENVIRONMENT
41 .Bl -tag -width Ds
42 .It Ev DEBUG
+7,
-0
1@@ -0,0 +1,7 @@
2+# OpenBSD login.conf(5) entry to increase the openfiles for the snac login
3+# class. Further documented under "Number of open files on OpenBSD and login
4+# classes" in snac(8).
5+
6+snac:\
7+ :openfiles=4096:\
8+ :tc=daemon:
M
httpd.c
+3,
-2
1@@ -1116,9 +1116,10 @@ void httpd(void)
2 FILE *f = fdopen(cs, "r+");
3 xs *job = xs_data_new(&f, sizeof(FILE *));
4 job_post(job, 1);
5- }
6- else
7+ } else {
8+ srv_log(xs_fmt("error: xs_socket_accept failed: %s", strerror(errno)));
9 break;
10+ }
11 }
12 }
13