You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows: a port another process holds on 0.0.0.0 counts as free #226
port_in_use (crates/devstack-daemon/src/supervisor/mod.rs) probes a port by binding 127.0.0.1:<port> and [::1]:<port>. On Windows that bind succeeds while a process of the same user listens on 0.0.0.0:<port> (Windows lets a more specific address bind over a wildcard unless the first socket used SO_EXCLUSIVEADDRUSE). So devstack takes the port to be free when it is not.
Found while adding macOS (ADR-0054, #225), where BSD sockets behave the same way. The test a_port_held_on_every_address_is_in_use reproduces it: it fails on Windows and is gated with #[cfg(not(windows))] for now.
What it affects: every caller of port_in_use: the start checks in supervisor/lifecycle.rs, port choice for lanes (lanes.rs), forwarded ports of lanes on nodes (remote.rs), and devstack doctor. Typical holders on 0.0.0.0: a dev server started with --host 0.0.0.0, Docker Desktop's published ports, anything bound to "all interfaces". The service devstack then starts fails with "address in use" (or, for a server that binds 127.0.0.1, both run and the browser reaches whichever Windows picks).
Why not the macOS fix: macOS now also asks with a connect (answers_locally). On Windows a connect to a closed loopback port takes about two seconds of SYN retries, and lanes.rs probes ranges of ports.
Options:
Bind the wildcard too (0.0.0.0, ::) with socket2, without listen(), so Windows Defender Firewall does not ask. A bind on the wildcard fails with WSAEADDRINUSE while anyone holds the port on any address. Check that a bound but unlistened socket really triggers no prompt.
Read the TCP table (GetExtendedTcpTable, already how port_holder finds names via netstat -ano) and treat a LISTEN row on 0.0.0.0/:: for the port as taken.
A connect with a short timeout (≤ 50 ms) only for the single-port checks, not for range scans.
Done when:a_port_held_on_every_address_is_in_use runs and passes on windows-latest too.
Activity
test: listeners on every address only in CI on Windows, so the firewa…