• docs/v322_new.md src/sbbs3/ftpsrvr.cpp mailsrvr.cpp main.cpp websrvr.c

    From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Tue Nov 10 22:33:54 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/3592004a31ca096b15faeafd
    Modified Files:
    docs/v322_new.md src/sbbs3/ftpsrvr.cpp mailsrvr.cpp main.cpp websrvr.cpp src/xpdev/multisock.c multisock.h
    Log Message:
    Close server listening sockets as soon as shutdown begins

    The terminal, mail, FTP, and web servers kept their listening sockets open until cleanup(), which runs only after the wait for active clients and
    child threads. Nothing calls accept() during that wait, but the kernel
    still completes TCP handshakes into the listen backlog, so every client
    that connected during a shutdown or recycle sat on an unanswered
    connection until the sockets finally closed, then got a reset. On a busy
    web server that drain can last two minutes.

    Add xpms_close() to xpdev, which closes a set's sockets but leaves the set allocated, and call it in each server right after its accept loop exits. xpms_destroy() now uses it. The set must stay allocated rather than being destroyed early because the FTP transfer threads treat ftp_set == NULL as "server torn down": clearing it at the start of a recycle would abort in-progress transfers. The services server already closed its sockets at
    this point.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Thu Dec 3 19:26:30 2026
    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