loopd: read on a socket whose peer closed, instead of failing on macOS
macOS refuses every socket option with EINVAL once the peer has closed (XNU sosetoptlock, bsd/kern/uipc_socket.c), even with unread data still buffered. loopd set a read timeout before each read, so on macOS every frame or response that arrived just before the peer closed was lost: BrokerPort reported the broker unavailable with "os error 22", and the llama client failed the same way. Twelve loopd test binaries failed on macOS; Linux never refuses, so the gate on Talos did not see it. Both places now go through socket::set_read_timeout, which on Apple targets takes that one refusal as success: a socket shut in both directions returns its data or the end at once and cannot block. A zero timeout is still an error. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -151,9 +151,7 @@ impl Connection {
|
||||
}
|
||||
|
||||
pub fn set_read_timeout(&self, timeout: Duration) -> Result<(), HttpError> {
|
||||
self.stream
|
||||
.set_read_timeout(Some(timeout))
|
||||
.map_err(HttpError::Io)
|
||||
crate::socket::set_read_timeout(&self.stream, timeout).map_err(HttpError::Io)
|
||||
}
|
||||
|
||||
pub fn received_any(&self) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user