cultmesh-py: bind the TCP+UDP pair for port 0 without the race #34
Loading…
Reference in a new issue
No description provided.
Delete branch "libby/cultmesh-py-port-race"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
CultMeshLocalServer.startbound 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 withEADDRINUSE, 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_socketsbinds 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