Skip to content

Non-blocking send queue on EAGAIN - #8

Merged
vimpop merged 1 commit into
mainfrom
improve_socketio_blocking
Jan 24, 2026
Merged

Non-blocking send queue on EAGAIN#8
vimpop merged 1 commit into
mainfrom
improve_socketio_blocking

Conversation

@vimpop

@vimpop vimpop commented Jan 24, 2026

Copy link
Copy Markdown
Owner

PR: Outbound send queue on EAGAIN

Summary

Replace the single deferred packet buffer with a per-player outgoing queue so sends remain ordered and non-blocking. Packets are sent immediately when possible and queued only when the socket returns EAGAIN/EWOULDBLOCK.

Key changes

  • Added out_packet_t and per-player queue pointers in include/UCraft/player.h, removing the legacy packet_dispatch_event path.
  • Updated sendData() to report blocking via an out param and return early on EAGAIN/EWOULDBLOCK.
  • Implemented queueing and flushing in src/socketio.c, with cleanup of queued packets in src/player.c.
  • Simplified the send loop in src/UCraft.c to sendDispatch() + sendFlush().
  • Moved errno include to include/UCraft/wrapper_unix.h and include/UCraft/wrapper_win.h after removing it from include/UCraft/socketio.h.

Behavior

  • If the socket is writable, sendDispatch() sends immediately and does not queue.
  • If a send blocks, the unsent tail is queued and later flushed in order by sendFlush().

Note

AI assistance was used during the implementation (codex). Human intervention was involved though!

@vimpop
vimpop merged commit 1ff2e1d into main Jan 24, 2026
4 checks passed
@vimpop
vimpop deleted the improve_socketio_blocking branch January 24, 2026 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant