Handle EOF on one side of a UnixSocketRelay. (#323)

- Current implementation shuts down everything as soon as EOF is
detected on DispatchSourceRead for the relay. This is problematic for,
say an HTTP request where the client makes a request, and calls
`shutdown(fd, SHUT_WR)` to close the send side, but it expects to be
able to keep calling `recv()` to get the response.
- Changed cancel handlers so that the one that sees that both sources
have been cancelled then closes both the UDS and vsock fds.
- Updated vminitd VsockProxy to also do `shutdown(fd, SHUT_WR)` for read
hangup or EOF, and only close the underlying fds and unwire pollers on
full hangup, broken pipe, error, or when both sides half-close.
This commit is contained in:
J Logan authored and GitHub committed 2025-10-24 13:13:13 -07:00
1 parent 57ad7ad629
commit 6f7601e475
4 files changed
+292 -54

No files matched your search

+5 -1
View File
@@ -169,7 +169,11 @@ public final class Epoll: Sendable {
extension Epoll.Mask {
public var isHangup: Bool {
(self & (EPOLLHUP | EPOLLERR | EPOLLRDHUP)) != 0
(self & (EPOLLHUP | EPOLLERR)) != 0
}
public var isRhangup: Bool {
(self & EPOLLRDHUP) != 0
}
public var readyToRead: Bool {