commit 5b971887f718b1d124236e851d4bde751213b4b4 from: Omar Polo date: Sat Sep 06 14:35:26 2025 UTC sockets_launch: simplify listen() handling * clean up the SOCKS_BACKLOG versus SOMAXCONN usage * factor out just one listen() call * slightly improve the logging by showing the socket "name" too. ok stsp@ commit - 28ad1c18bb74647f37660ec576b5d8e7e6386955 commit + 5b971887f718b1d124236e851d4bde751213b4b4 blob - 14e2eca5e33aa5640070e3a4b9ef8634b2c05f64 blob + f2cc7a4eb8d7c88ef03073b64897e2a73685cc29 --- gotwebd/sockets.c +++ gotwebd/sockets.c @@ -320,6 +320,7 @@ static void sockets_launch(struct gotwebd *env) { struct socket *sock; + const char *sockname; int i, have_unix = 0, have_inet = 0; if (env->iev_fcgi == NULL) @@ -328,30 +329,20 @@ sockets_launch(struct gotwebd *env) fatal("gotweb process not connected"); TAILQ_FOREACH(sock, &gotwebd_env->sockets, entry) { - log_info("%s: configuring socket %d (%d)", __func__, - sock->conf.id, sock->fd); - - switch (sock->conf.af_type) { - case AF_UNIX: - if (listen(sock->fd, SOCKS_BACKLOG) == -1) { - fatal("cannot listen on %s", - sock->conf.unix_socket_name); - } - have_unix = 1; - break; - case AF_INET: - case AF_INET6: - if (listen(sock->fd, SOMAXCONN) == -1) { - fatal("cannot listen on %s", - sock->conf.addr.ifname); - } + if (sock->conf.af_type == AF_UNIX) { + have_unix = 1; + sockname = sock->conf.unix_socket_name; + } else { have_inet = 1; - break; - default: - fatalx("unsupported address family type %d", - sock->conf.af_type); + sockname = sock->conf.addr.ifname; } + log_info("%s: configuring socket %s %d (%d)", __func__, + sockname, sock->conf.id, sock->fd); + + if (listen(sock->fd, SOCKS_BACKLOG) == -1) + fatal("cannot listen on %s", sockname); + event_set(&sock->ev, sock->fd, EV_READ | EV_PERSIST, sockets_socket_accept, sock);