https://gitlab.synchro.net/main/sbbs/-/commit/4cf669c29f3defee154aa717
Modified Files:
docs/v322_new.md src/sbbs3/ftpsrvr.cpp mailsrvr.cpp main.cpp websrvr.cpp src/xpdev/multisock.c multisock.h
Log Message:
A port that can't be bound no longer stalls a server's other listeners
Each server adds its listeners with xpms_add_list() before entering its
accept loop, and a failed bind went through retry_bind(), which sleeps BindRetryDelay between up to BindRetryCount attempts. So one port owned
by another program (OpenSSH on port 22, on a fresh Raspberry Pi OS
install with ALLOW_SSH) kept the Terminal Server from accepting on any
port, Telnet included, for minutes: clients connected, got no output, and
the BBS looked hung. The wait was also paid separately for each address
family (IPv4, then IPv6) of the same port.
A socket set can now be marked defer_failed_binds. In such a set a
failed bind is tried once, logged, and the unbound socket is queued; xpms_accept() binds the queued sockets again as they come due (same count
and delay as before, all ports on the same schedule, timed with the
monotonic xp_timer64()) and shortens its wait to reach the next retry, so
the listeners that did bind are served from the start. Retrying on the
same socket, as retry_bind() did, means each listener's sock_init
callback (socket options, the socket_open counter) still runs once. A
bind that succeeds later logs "listening on socket" then; one that never
does logs the final error at LOG_CRIT, as before. EACCES/EPERM are not
retried: waiting does not fix them. xpms_close() closes the queued
sockets through its sock_destroy callback, so nothing is bound after
shutdown begins.
The Terminal, Mail, FTP and Web servers set the flag. The Services server (which polls the set's sockets itself, with arrays sized at startup) and
JS ListeningSocket (whose constructor reports a failed bind) keep the
blocking retries.
Also:
- xpms_accept() on a set with no sockets now waits for its timeout
instead of returning at once, which spun a server's accept loop when
none of its ports could be bound.
- The Terminal Server no longer reads socks[0] of a set that has no
sockets yet (it is only logged by the sbbs_t constructor).
Fixes #1451
Co-Authored-By: Claude Opus 5.5 <
noreply@anthropic.com>
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net