Skip to content

fix: support TCP keepalive socket options - #140

Closed
syrusakbary wants to merge 2 commits into
mainfrom
codex/tcp-keepalive-options
Closed

syrusakbary wants to merge 2 commits into
mainfrom
codex/tcp-keepalive-options

Conversation

@syrusakbary

@syrusakbary syrusakbary commented Sep 25, 2026 •

Copy link
Copy Markdown

This full TCP keepalive timing work is no longer required for the Pi integration. Edge.js #155 uses the existing basic SO_KEEPALIVE option in its native WASIX binding and skips unsupported timing options. Pi works with the stock libc and original WISP transport. Full configurable probe timing is deferred; Wasmer #7035 and libuv #15 are being kept focused on filesystem timestamps.


Summary

WASIX libc rejects TCP_KEEPIDLE, TCP_KEEPINTVL, and TCP_KEEPCNT before calling the runtime. Extend the existing TCP option translation and route these three options through the existing integer socket-option getter/setter, so libuv can use its normal setsockopt calls.

The implementation adds 26 net lines across setsockopt.c and getsockopt.c. There are no separate keepalive handlers or new helper functions. Wasmer validates keepalive values; libc handles buffer sizes/copying and propagates runtime errors. The shared getter preserves truncated/zero-length output semantics, and the shared setter reads values without assuming alignment. Existing public TCP constant values remain unchanged.

The rest of the diff defines/generated-checks the three WASIX option IDs and adds a loopback C regression. WITX #10 appends IDs without changing existing IDs or syscall signatures. Companion runtime: Wasmer #7035. libuv #15 remains timestamp-only, with no socket workaround.

Validation

  • Rebuilt exnref libc with CHECK_SYMBOLS=yes: exported/undefined symbols, public headers, and exact predefined-macro snapshots pass.
  • C regression compiled with -Wall -Wextra -Werror and passed against the updated Wasmer CLI using the simplified libc. Covers keepalive before/after connection, updates, invalid values/buffers, closed descriptors, and truncated/zero-length getters.
  • The same output-buffer regression also passes for SO_RCVBUF, verifying the reused integer-option path.
  • The previous implementation was additionally validated with unmodified libuv TCP calls, rebuilt Edge.js, and full Pi browser integration; this refactor retains the option ABI and runtime behavior.

Requires the updated Wasmer runtime; no sysroot package or runtime release is published by this PR. Commits are authored by Codex.

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.

2 participants