From cab81d3fa96268472a121d8920fc59a9caa483df Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 17 Aug 2024 10:36:46 +0200 Subject: [PATCH] extend comments on HUP vs RDHUP --- src/tools/miri/src/shims/unix/linux/epoll.rs | 3 +++ src/tools/miri/src/shims/unix/socket.rs | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tools/miri/src/shims/unix/linux/epoll.rs b/src/tools/miri/src/shims/unix/linux/epoll.rs index a47d9fe0826d..53f27868aeb9 100644 --- a/src/tools/miri/src/shims/unix/linux/epoll.rs +++ b/src/tools/miri/src/shims/unix/linux/epoll.rs @@ -71,6 +71,9 @@ pub struct EpollReadyEvents { pub epollrdhup: bool, /// For stream socket, this event merely indicates that the peer /// closed its end of the channel. + /// Unlike epollrdhup, this should only be set when the stream is fully closed. + /// epollrdhup also gets set when only the write half is closed, which is possible + /// via `shutdown(_, SHUT_WR)`. pub epollhup: bool, } diff --git a/src/tools/miri/src/shims/unix/socket.rs b/src/tools/miri/src/shims/unix/socket.rs index f7c168c58b97..3f2adb6e79c4 100644 --- a/src/tools/miri/src/shims/unix/socket.rs +++ b/src/tools/miri/src/shims/unix/socket.rs @@ -69,7 +69,8 @@ impl FileDescription for SocketPair { epoll_ready_events.epollout = true; } } else { - // Peer FD has been closed. + // Peer FD has been closed. This always sets both the RDHUP and HUP flags + // as we do not support `shutdown` that could be used to partially close the stream. epoll_ready_events.epollrdhup = true; epoll_ready_events.epollhup = true; // Since the peer is closed, even if no data is available reads will return EOF and