Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion brain-bar/Sources/BrainBar/BrainBarServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ final class BrainBarServer: @unchecked Sendable {
if !response.isEmpty {
sendResponse(fd: fd, response: response)
}
// sendResponse may have called disconnectClient — stop processing
if clients[fd] == nil { return }
}

clients[fd] = state
Expand Down Expand Up @@ -200,7 +202,11 @@ final class BrainBarServer: @unchecked Sendable {
disconnectClient(fd: fd)
return
}
if n == 0 { break } // EOF
if n == 0 {
NSLog("[BrainBar] Write returned 0 on fd %d — peer closed", fd)
disconnectClient(fd: fd)
return
}
totalWritten += n
eagainRetries = 0 // reset on successful partial write
}
Expand Down
Loading