commit 049c14ecdfe61442b223d8e4995acca2b557624e from: Omar Polo via: Thomas Adam date: Sat Sep 06 16:29:36 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 - 94f3c56922948adc179cb260c0fd16a34d891d1b commit + 049c14ecdfe61442b223d8e4995acca2b557624e blob - 882a9acc2dc56c4f09cba12664713fd75c3590b7 blob + 1a5dfceec28e4ec209e93323844f9bb122707357 --- 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);