• src/sbbs3/mqtt_broker.cpp mqtt_broker.h

    From Deucе@1:103/705 to Git commit to main/sbbs/master on Sun May 10 19:29:42 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/7c52f1a90e33431d5824fc46
    Modified Files:
    src/sbbs3/mqtt_broker.cpp mqtt_broker.h
    Log Message:
    mqtt_broker: fix session map key collision on socket descriptor reuse

    Sessions were keyed by "pending-{socket}" strings. When a client
    disconnected, the session stayed in the map with socket=-1. When
    the OS reused the socket descriptor for a new connection, the old
    dead session was silently overwritten, corrupting broker state and
    causing subsequent connections to fail.

    Fix: key sessions by SOCKET descriptor directly. Dead sessions are
    erased before creating new entries for the same descriptor. Cleanup (unsubscribe, will delivery) now happens before socket close to
    ensure the descriptor isn't reused while cleanup is in progress.

    Also: use INVALID_SOCKET consistently instead of -1 for invalid
    socket descriptors (portability).

    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
    --- SBBSecho 3.37-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)