• Server shutdown: unbounded child-thread waits (FTP, Mail, Services), a

    From Rob Swindell@1:103/705 to GitLab issue in main/sbbs on Tue Nov 10 22:16:46 2026
    open https://gitlab.synchro.net/main/sbbs/-/work_items/1333

    ## Summary

    When a server shuts down or recycles, a child thread that is blocked somewhere other than its client socket (a script stuck in a native call, a CGI/FastCGI pipe, a mutex, file I/O on a stalled network share) holds up the shutdown. How each server handles that differs:

    | Server | Wait for child threads | After giving up |
    |---|---|---|
    | Web | bounded: `TIMEOUT_THREAD_WAIT` (60 s), re-kicking client sockets every 5 s | frees shared state while the stuck threads still run |
    | FTP | **unbounded** | n/a |
    | Mail | **unbounded** | n/a |
    | Terminal | node threads: 60 s; events thread: **unbounded** (its timeout is `#if 0`'d because the thread "can/will segfault if it continues to run and dereference sbbs->cfg") | frees `events`/`sbbs` only if those threads have stopped |
    | Services | dynamic clients and static services: **unbounded** | n/a |

    Code references are as of master ab31f9f1c0 (flux-3-skip, 2026-11-10).

    ## Unbounded waits (FTP, Mail)

    `ftpsrvr.cpp` `cleanup()` (`:5355-5361`) and `mailsrvr.cpp` `cleanup()` (`:6359-6364`) loop on `thread_count > 1` with `mswait(100)` and no time limit or re-kick. One stuck thread holds the server, and under systemd the whole `sbbs` process, until the stop timeout kills it (SIGKILL, no orderly cleanup). Services (`services.cpp:2681`, `:2703`) and the terminal server's events-thread wait (`main.cpp:6479-6491`) behave the same way.

    ## Freeing shared state after the timeout (Web)

    The web server bounded its wait in a45592ec5b (defend-45-tech, 2026-09-30). On timeout, `cleanup()` (`websrvr.cpp:7382`) logs `!TIMEOUT waiting for N child thread(s) to terminate` and continues straight into `free_cfg(&scfg)`, `listFree(&log_list)`, the `iniFree*` calls for `mime_types`, `cgi_handlers`, `xjs_handlers`, `alias_list`, `cgi_env`, the semfile lists, and `listFree(&current_connections)`, while those threads still run and may touch any of it when they wake.

    - On **shutdown** the process exits shortly afterwards, so the window is small, though not zero.
    - On **recycle** the process keeps running: `cleanup(0)` (`:8215`) is followed by a re-read of the configuration, and a stuck session that wakes later dereferences freed or reloaded `scfg`, MIME/handler lists, and so on. That's a use-after-free.

    This was observed in production on 2026-11-10: a web server shutdown ended with `!TIMEOUT waiting for 9 child thread(s) to terminate` and `!!!! Terminating with 8 child thread(s) still running`. The periodic `shutdown_sessions()` kicks logged nothing, so none of the 9 threads still had a registered client connection, i.e. they were blocked off-socket.

    ## Suggested direction

    - Give FTP and Mail the same bounded, re-kicking wait the web server has.
    - On a timeout, don't free state the stuck threads can still reach. Either leak it deliberately (acceptable on shutdown, since the process is exiting) or skip the recycle and fall back to a full stop/restart when threads are left behind, so a stray thread never sees a reloaded configuration.
    - Apply the same rule to the web server's existing timeout path.
    - Log what each remaining thread is (session/socket, client IP, current request or script) when the wait times out, so the blocking call can be identified from the log alone.

    *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Michael J. Ryan@1:103/705 to GitLab note in main/sbbs on Tue Nov 10 22:22:17 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1333#note_10866

    Is this related to the web server on vert sometimes taking 30-60s to load/respond?

    I tried loading the email screen and it just didn't after waiting 2+ minutes. --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Rob Swindell@1:103/705 to GitLab note in main/sbbs on Wed Nov 11 13:01:29 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1333#note_10875

    No, that's likely other I/O issues (with Samba). use web.synchro.net to access Vertrauen's web interface (not vert.synchro.net) and you should have a lot better experience.
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Rob Swindell@1:103/705 to GitLab note in main/sbbs on Wed Nov 11 13:59:07 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1333#note_10881

    @tracker1 the mail page you couldn't load is fixed, and it turned out to be its own bug rather than this issue or the Samba I/O: the page looked up every message *number* between the first and last message in the mail base, one at a time (24,870 lookups for 9,262 messages on Vertrauen), which took almost 6 minutes for a logged-in user. It now reads the mail index once and fetches only your own messages' headers.

    Fixed in c5f0ca87d9 and live on vert.synchro.net now; the same page load takes about 5 seconds there. Other pages on vert.synchro.net can still be slow for the unrelated reasons mentioned above, so web.synchro.net remains the faster way in.

    — *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Michael J. Ryan@1:103/705 to GitLab note in main/sbbs on Wed Nov 11 14:18:49 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1333#note_10883

    @rswindell cool, thanks.
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From kk4qbn@1:103/705 to Rob Swindell on Wed Nov 11 19:35:29 2026
    Re: Server shutdown: unbounded child-thread waits (FTP, Mail, Services), a
    By: Rob Swindell to GitLab note in main/sbbs on Wed Nov 11 2026 13:59:07

    @tracker1 the mail page you couldn't load is fixed, and it turned out to be its
    own bug rather than this issue or the Samba I/O: the page looked up every message *number* between the first and last message in the mail base, one at a
    time (24,870 lookups for 9,262 messages on Vertrauen), which took almost 6 minutes for a logged-in user. It now reads the mail index once and fetches only
    your own messages' headers.

    Thanks! and thanks Tracker1, the email hasnt been loading on my website for quite some time (probably has been loading, but I wasnt patient enough to wat over 30 sec) I truly thought it was something I had done to break it and kept looking and looking for an issue. works like a champ meow.




    Tim (kk4qbn)

    ---
    þ Synchronet þ kk4qbn bbs: Northwest GA, telnet/www kk4qbn.synchro.net
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)