Skip to content

wasix: enable SO_REUSEPORT in uv__sock_reuseport#9

Open
Arshia001 wants to merge 1 commit into
fix/wasix-ipc-plain-readfrom
fix/wasix-reuseport
Open

wasix: enable SO_REUSEPORT in uv__sock_reuseport#9
Arshia001 wants to merge 1 commit into
fix/wasix-ipc-plain-readfrom
fix/wasix-reuseport

Conversation

@Arshia001

Copy link
Copy Markdown

Stacked on #8.

uv__sock_reuseport only whitelisted Linux/DragonFly/AIX/Solaris, so uv_tcp_bind/uv_udp_bind with UV_[TCP/UDP]_REUSEPORT failed UV_ENOTSUP under WASIX before the runtime was ever consulted. The full path below the gate works: wasix-libc maps setsockopt(SO_REUSEPORT) to sock_set_opt_flag, and wasmer applies SO_REUSEPORT to the underlying host socket before bind — so the load-balancing semantics are the host kernel's (Linux in practice).

Verified with an EdgeJS guest on wasmer 7.2.0-rc.1:

  • two reusePort listeners in one process bind the same port
  • a listener without the flag still fails EADDRINUSE
  • two forked guest processes listening on the same port split 40 connections 18/22 (kernel balancing)
  • Node's test-dgram-reuseport.js passes (it previously skipped on ENOTSUP)

This is the enabling primitive for a reuseport-based cluster scheduling strategy on WASIX (workers bind the shared port themselves instead of receiving handles via SCM_RIGHTS).

🤖 Generated with Claude Code

uv__sock_reuseport only whitelisted Linux/DragonFly/AIX/Solaris, so
uv_tcp_bind/uv_udp_bind with UV_[TCP/UDP]_REUSEPORT failed UV_ENOTSUP
under WASIX before the runtime was ever consulted. The full path below
works: wasix-libc maps setsockopt(SO_REUSEPORT) to sock_set_opt_flag and
wasmer applies SO_REUSEPORT to the underlying host socket before bind, so
the load-balancing semantics are the host kernel's (Linux in practice).

Verified with an EdgeJS guest on wasmer 7.2.0-rc.1: two listeners in one
process bind the same port; a listener without the flag still fails
EADDRINUSE; two forked guest processes listening on the same port split
40 connections 18/22; Node's test-dgram-reuseport.js passes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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