https://gitlab.synchro.net/main/sbbs/-/commit/8101584ded3352342328fcb6
Modified Files:
src/sbbs3/main.cpp
Log Message:
Terminal server: shutdown(), don't close(), node sockets at terminate/recycle
At server termination/recycle, the terminal server thread force-
disconnected active nodes by calling close_socket() on each node's client socket. But that descriptor is owned by the node thread: sbbs_t::hangup() closes it again during the node's own teardown (after its 1-second output- flush mswait), producing a double-close. On *nix that logged the (benign
but alarming) shutdown-time noise:
!ERROR 9 closing socket 11
one second after 'Closing node N socket 11'; on Windows the same double-
close was silent only because close_socket() exempts ENOTSOCK. Worse than
the noise: between the two closes the fd number could be reused (a new
inbound connection during recycle, an opened file) and hangup() would then close an unrelated descriptor out from under its new owner.
Shut the socket down (SHUT_RDWR) instead of closing it: that wakes every blocked reader -- and unlike close(), propagates EOF through dup'd
descriptors held by external programs -- while the fd number stays
allocated until the owning node thread performs the one real close in
hangup(). node_socket[] is still marked INVALID_SOCKET here, preserving
the input_thread 'shutdown locally' signal that terminates JS execution promptly.
Same fd-lifetime family as 39112546f2 (tables-20-ideas) / issue #1184. Validated against a live scratch terminal server: SIGTERM with an active
client session now yields a clean 'Shutting down node 1 socket 11' ->
'Node 1 disconnected' -> node-thread-terminated sequence with no EBADF
errors logged.
Co-Authored-By: Claude Fable 5 <
noreply@anthropic.com>
--- SBBSecho 3.37-Linux
* Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)