commit c29d691

Alvar Penning  ·  2026-02-17 21:55:29 +0000 UTC
parent 787d018
httpd: Log xs_socket_accept failure reason

So far, it was expected that xs_socket_accept should work and while its
failure results in a termination, it was not properly logged. With this
change, an error message including the strerror message is being logged.

After experiencing some unexpected snac httpd shutdowns, I added a bit
of additional logging, including when xs_socket_accept fails. This
proved useful, as it unveiled a deeper error on my machine:

> xs_socket_accept failed: Too many open files

Since entering this code path results in termination, I thought
upstreaming this logging might be useful for others.
1 files changed,  +3, -2
+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