sys_util: Include EPOLLRDHUP in hangup checks.

TCP uses EPOLLRDHUP to indicate when the other side has sent a FIN.
Include EPOLLRDHUP in the hangup checks so TCP connections can be used
with the poll module.

BUG=None
TEST=manatee shell works in interactive mode.

Change-Id: I39d0527d992ee915f8b807a7ee75f831bc92b26a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3244224
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Allen Webb <allenwebb@google.com>
This commit is contained in:
Allen Webb 2021-10-25 18:57:03 -05:00 committed by Commit Bot
parent 5d5192a7f6
commit f28bca1ddc

View file

@ -16,7 +16,7 @@ use std::time::Duration;
use libc::{
c_int, epoll_create1, epoll_ctl, epoll_event, epoll_wait, EPOLLHUP, EPOLLIN, EPOLLOUT,
EPOLL_CLOEXEC, EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD,
EPOLLRDHUP, EPOLL_CLOEXEC, EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD,
};
use crate::{errno_result, Result};
@ -139,7 +139,7 @@ impl<'a, T: PollToken> PollEvent<'a, T> {
/// True if the `fd` associated with this token in `PollContext::add` has been hungup on.
pub fn hungup(&self) -> bool {
self.event.events & (EPOLLHUP as u32) != 0
self.event.events & ((EPOLLHUP | EPOLLRDHUP) as u32) != 0
}
}
@ -218,7 +218,7 @@ impl<'a, T: PollToken> PollEvents<'a, T> {
/// Iterates over each hungup event.
pub fn iter_hungup(&self) -> PollEventIter<slice::Iter<epoll_event>, T> {
PollEventIter {
mask: EPOLLHUP as u32,
mask: (EPOLLHUP | EPOLLRDHUP) as u32,
iter: self.events[..self.count].iter(),
tokens: PhantomData,
}