mirror of
https://github.com/hanzoai/visor.git
synced 2026-09-24 17:04:14 +00:00
SCMSender.beforeSave disconnects the endpoint on save: it shuts down and closes the host fd, leaving fd = -1. Send already handles this state via its IsSendClosed check (beforeSave sets sendShutdown), so writes fail with EPIPE, but Recv had no guard and passed -1 to recvmsg(2), leaking EBADF to applications for an fd that is still valid in their fd table. Return ErrClosedForReceive instead, which the socket layer already surfaces as read() == 0, matching Linux EOF semantics for a socket whose read side is shut down and making a severed host endpoint behave like any socket whose peer has gone away. The guard keys on fd < 0 rather than IsRecvClosed: after a local SHUT_RD on a live fd, the host socket may still hold queued data that must be drained before EOF, and host recvmsg(2) handles that correctly. PiperOrigin-RevId: 976063849