Skip to content

Socket buffers: keep the OS default rather than fail; netcode 1.4.9 - #199

Merged
rowan-claude merged 1 commit into
mainfrom
rowan/sockbuf-keep-os-default
Oct 29, 2026
Merged

rowan-claude merged 1 commit into
mainfrom
rowan/sockbuf-keep-os-default

Conversation

@rowan-claude

Copy link
Copy Markdown
Contributor

On a stock NetBSD 11.0, netcode_server_create and client create fail. NetBSD's default kern.sbmax is 256 KiB, of which about 227 KiB is usable, and the socket-buffer back-off gave up below a 256 KiB floor with SOCKOPT_SNDBUF/RCVBUF_FAILED. yojimbo's new NetBSD VM leg found it.

A larger socket buffer is an optimisation, not a requirement. The back-off (netcode_socket_buffer_size_back_off) now halves the request down to 64 KiB, and if nothing is accepted the socket keeps the OS default and logs it at info. Socket creation no longer fails on this. The two error codes that only this path returned are removed. Linux, macOS and Windows behave as before: they clamp, so the first request is accepted. No wire or API change.

  • test_socket_buffer_size_back_off drives the back-off against a fake OS, with no sockets: one that accepts, a NetBSD-like limit (128 KiB accepted after five refusals), and one that refuses everything (OS default kept, nothing below the minimum requested). It fails with the old 256 KiB floor.
  • Local, macOS arm64: debug and release builds with zero warnings, ctest green.
  • The NetBSD proof is the yojimbo platform workflow with this netcode vendored and its kern.sbmax workaround removed (linked PR to follow).

Version 1.4.9.

🤖 Generated with Claude Code

A stock NetBSD 11.0 (kern.sbmax 256 KiB, about 227 KiB usable) refuses every
buffer request down to netcode's old 256 KiB floor, so socket create failed
and no server or client could start. A larger buffer is an optimisation, not
a requirement: the back-off now halves down to 64 KiB, and if nothing is
accepted the socket keeps the OS default. Found by yojimbo's NetBSD VM leg.

test_socket_buffer_size_back_off covers it with a fake OS, no sockets; it
fails with the old 256 KiB floor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rowan-claude
rowan-claude merged commit ced9b4b into main Oct 29, 2026
19 checks passed
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