mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Force registration for EPOLLHUP, not EPOLLRDHUP, in vfs2's epoll.
Compare Linux's fs/eventpoll.c:do_epoll_ctl(). I don't know where EPOLLRDHUP came from. PiperOrigin-RevId: 323874419
This commit is contained in:
@@ -186,7 +186,7 @@ func (ep *EpollInstance) AddInterest(file *FileDescription, num int32, event lin
|
||||
}
|
||||
|
||||
// Register interest in file.
|
||||
mask := event.Events | linux.EPOLLERR | linux.EPOLLRDHUP
|
||||
mask := event.Events | linux.EPOLLERR | linux.EPOLLHUP
|
||||
epi := &epollInterest{
|
||||
epoll: ep,
|
||||
key: key,
|
||||
@@ -257,7 +257,7 @@ func (ep *EpollInstance) ModifyInterest(file *FileDescription, num int32, event
|
||||
}
|
||||
|
||||
// Update epi for the next call to ep.ReadEvents().
|
||||
mask := event.Events | linux.EPOLLERR | linux.EPOLLRDHUP
|
||||
mask := event.Events | linux.EPOLLERR | linux.EPOLLHUP
|
||||
ep.mu.Lock()
|
||||
epi.mask = mask
|
||||
epi.userData = event.Data
|
||||
|
||||
@@ -422,6 +422,28 @@ TEST(EpollTest, CloseFile) {
|
||||
SyscallSucceedsWithValue(0));
|
||||
}
|
||||
|
||||
TEST(EpollTest, PipeReaderHupAfterWriterClosed) {
|
||||
auto epollfd = ASSERT_NO_ERRNO_AND_VALUE(NewEpollFD());
|
||||
int pipefds[2];
|
||||
ASSERT_THAT(pipe(pipefds), SyscallSucceeds());
|
||||
FileDescriptor rfd(pipefds[0]);
|
||||
FileDescriptor wfd(pipefds[1]);
|
||||
|
||||
ASSERT_NO_ERRNO(RegisterEpollFD(epollfd.get(), rfd.get(), 0, kMagicConstant));
|
||||
struct epoll_event result[kFDsPerEpoll];
|
||||
// Initially, rfd should not generate any events of interest.
|
||||
ASSERT_THAT(epoll_wait(epollfd.get(), result, kFDsPerEpoll, 0),
|
||||
SyscallSucceedsWithValue(0));
|
||||
// Close the write end of the pipe.
|
||||
wfd.reset();
|
||||
// rfd should now generate EPOLLHUP, which EPOLL_CTL_ADD unconditionally adds
|
||||
// to the set of events of interest.
|
||||
ASSERT_THAT(epoll_wait(epollfd.get(), result, kFDsPerEpoll, 0),
|
||||
SyscallSucceedsWithValue(1));
|
||||
EXPECT_EQ(result[0].events, EPOLLHUP);
|
||||
EXPECT_EQ(result[0].data.u64, kMagicConstant);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace testing
|
||||
|
||||
Reference in New Issue
Block a user