• src/ssh/ssh-conn.c ssh-internal.h ssh-trans.c ssh-trans.h ssh.c src/ss

    From Deuc¨@VERT to Git commit to main/sbbs/master on Wed Apr 1 16:21:56 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/a07679f5629813e780f84764
    Modified Files:
    src/ssh/ssh-conn.c ssh-internal.h ssh-trans.c ssh-trans.h ssh.c src/ssh/test/dssh_test_internal.h test_alloc.c test_chan.c
    Log Message:
    Replace TX queue linked list with pre-allocated slot buffers

    Eliminate all malloc/free from the demux thread's fire-and-forget
    send path by replacing the linked-list TX queue with pre-allocated, algorithm-correctly-sized packet buffers ("slots").

    Session-level slots: global_reply (REQUEST_SUCCESS/FAILURE, 1B),
    open_fail (CHANNEL_OPEN_FAILURE, 16B). Channel-level slots:
    wa (WINDOW_ADJUST, 9B), chan_fail (CHANNEL_FAILURE, 8B).

    Each slot buffer is sized to hold a complete wire packet for its
    max payload using the negotiated block_size and MAC digest, computed
    by tx_slot_buf_size(). Buffers are allocated in newkeys() after derive_and_apply_keys() and resized on rekey if algorithms change.

    tx_finalize() parameterized to operate on arbitrary buffers (not
    just sess->trans.tx_packet), enabling zero-copy finalize+send
    directly from slot buffers.

    send_to_slot() provides RX backpressure: fast path tries tx_mtx
    and sends immediately; slow path stalls the demux thread on
    tx_slot_cnd until the slot is drained, blocking recv_packet and
    causing TCP backpressure on a misbehaving peer.

    send_to_wa_slot() coalesces WINDOW_ADJUST via saturating add on
    the bytes field when the slot is already occupied Ä no stall needed.

    Accept queue converted from unbounded malloc'd linked list to
    fixed-capacity ring buffer (DSSH_ACCEPT_QUEUE_CAP=8) embedded in
    the session struct. Demux stalls on accept_cnd when full, closing
    the memory starvation vector from CHANNEL_OPEN floods.

    Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net