socket() failure inside the probe unlinks a live server’s socketSeverity: HIGH (split-brain: two servers, orphaned clients)
Status: ✅ FIXED
Files: src/server/socket.zig:48-75
createListener probes before unlinking (the #378 fix — never steal a live server’s socket):
if (connectProbeUnix(path)) |_| {
return error.AddressInUse; // live server: refuse
} else |_| {
// ECONNREFUSED etc. — stale socket from a dead server: safe to replace.
}
_ = c.unlink(path.ptr);
But connectProbeUnix creates its probe socket internally (c.socket(AF_UNIX, SOCK_STREAM, 0)), and the else |_| swallows every error — including that socket() call failing with EMFILE/ENFILE under fd exhaustion. So when the machine is out of fds, the probe “fails”, the code concludes the socket is stale, unlinks a live server’s socket path, and binds a second server there. New clients go to the new server; the old server’s clients stay connected to an orphaned instance. Split-brain with no error surfaced.
Distinguish probe stages: only ECONNREFUSED/ENOENT on the connect() itself mean “stale”; propagate socket()-creation errors (and unexpected connect() errors) instead of treating them as stale:
fn connectProbeUnix(path) Error!void {
const fd = mapErr(c.socket(...)) catch |err| return err; // never "stale"
...
}
and in createListener, only unlink on the specific stale indicators.
connectProbeUnix in src/server/socket.zig returns Error!ProbeResult (.live or .stale). It propagates socket creation and unexpected connect errors, classifying only ECONNREFUSED and ENOENT as .stale. createListener checks probe == .live and returns error.AddressInUse without unlinking.
Tests: connectProbeUnix returns stale for nonexistent path — bug #488 validates that nonexistent socket paths return ProbeResult.stale.