cultmesh-py: bind the TCP+UDP pair for port 0 without the race #34

Merged
libby merged 1 commit from libby/cultmesh-py-port-race into main 2026-11-07 19:28:51 +00:00
Member

CultMeshLocalServer.start bound TCP to port 0, then bound UDP to the number the kernel picked. When another process held that number for UDP (this host has ~370 UDP listeners) the start failed with EADDRINUSE, different tests each run, and once the daemon never published readiness. It also left the accept thread running after a failed start.

Fix at the owner: _bind_sockets binds both sockets before any thread starts; port 0 retries with a fresh pair (64 attempts); an explicit port still fails honestly with nothing left open. No test-side retries.

Tests: test_server_bind.py (UDP collision retries; explicit-port failure leaves no thread or listener); both fail on the old code. Suite: 11 consecutive full cultmesh-py runs green (139 tests), cultnet-py 142 OK.

🤖 Generated with Claude Code

`CultMeshLocalServer.start` bound TCP to port 0, then bound UDP to the number the kernel picked. When another process held that number for UDP (this host has ~370 UDP listeners) the start failed with `EADDRINUSE`, different tests each run, and once the daemon never published readiness. It also left the accept thread running after a failed start. Fix at the owner: `_bind_sockets` binds both sockets before any thread starts; port 0 retries with a fresh pair (64 attempts); an explicit port still fails honestly with nothing left open. No test-side retries. Tests: `test_server_bind.py` (UDP collision retries; explicit-port failure leaves no thread or listener); both fail on the old code. Suite: 11 consecutive full cultmesh-py runs green (139 tests), cultnet-py 142 OK. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
cultmesh-py: bind the TCP+UDP pair for port 0 without the race
Some checks failed
CultMesh QUIC native / Build win32-x64 (pull_request) Has been skipped
CultMesh QUIC native / Build linux-x64 (pull_request) Has been skipped
CultMesh QUIC native / Release native binaries (pull_request) Has been skipped
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Failing after 4m46s
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (pull_request) Successful in 46s
e0f5e13a1b
CultMeshLocalServer.start bound TCP to port 0 and then bound UDP to whatever number
the kernel picked, failing with EADDRINUSE whenever another process held that
number for UDP (this host has hundreds of UDP listeners), and left the accept
thread running on failure. Port 0 now retries with a fresh pair (bounded); both
sockets bind before any thread starts; an explicit port still fails honestly.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
libby merged commit 608ddb94f7 into main 2026-11-07 19:28:51 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
GameCult/CultLib!34
No description provided.