aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2026-07-09 18:42:32 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2026-07-09 18:42:32 -0700
commite4eb0c07010a32db3cf68083b2d63f9ceb21e009 (patch)
tree7ad11192f37035432eb9d6eed9813ab18161ebce /cmd
parentfff87ed2d3791d6853529457cc37689e8869b270 (diff)
Force-close accepted connections and drain session goroutines on shutdown
Canceling the server context closed only the listeners: sessions and file transfers never observed cancellation, so their goroutines kept running after ListenAndServe returned, blocked in reads until the remote side went away. Nothing joined them either, so shutdown raced whatever work was still in flight. The server now tracks every accepted connection (sessions and file transfers) in a registry. After the serve loops stop, ListenAndServe force-closes the tracked connections, which unblocks their read loops, and waits on a WaitGroup covering every session, file transfer, and client writer goroutine before returning. Connections that race in after shutdown begins are closed on arrival. The registry initializes lazily so test-constructed Servers keep working. The 3-second Windows close workaround in handleFileTransfer is skipped when the context is canceled so in-flight transfers do not delay process exit, and the transfer goroutine no longer assigns its error to the accept loop's captured variable.
Diffstat (limited to 'cmd')
0 files changed, 0 insertions, 0 deletions