mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-20 13:09:33 +01:00
port_in_use() connected with bash's /dev/tcp and waited for the answer. A listening port answers at once and a closed one is normally refused at once, but on WSL a connect to a closed 127.0.0.1 port is dropped and only fails at the kernel's connect timeout, minutes later (measured: still waiting after 10 s; ::1 is refused at once). The first-run port search tries up to 100 ports from 3000 and the start path checks the chosen port again, so a first run on WSL stalled. Each connect now runs in a background subshell that port_answers() waits on for at most 20 x 50 ms, then kills; no answer in time reads as free. Bash 3.2 clean: no `timeout` (macOS ships none), no `wait -n`. Test: a python3 listener with a full accept queue (Linux drops further SYNs, the same no-answer a WSL closed port gives) must be given up on within 3 s; a listening port and a closed one still answer at once. With the old unbounded connect the first test fails at its 10 s cap.
429 B
429 B
aicodeman
| aicodeman |
|---|
| patch |
docker/Start-Codeman.sh no longer hangs on WSL while it looks for a free port. On WSL a connect to a closed 127.0.0.1 port is dropped rather than refused and only fails at the kernel's connect timeout, so the first-run port search (up to 100 ports) and the check before docker compose up could stall for many minutes. Each port check now gives up after about a second and reads no answer as free.