1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:17:35 +00:00

Kernel: Stop reporting POLLHUP exclusively when available in sys$poll

As per Dr. Posix, unlike POLLERR and POLLNVAL, POLLHUP is only mutually
exclusive with POLLOUT, all other events may be reported together with
it.
This commit is contained in:
Idan Horowitz 2022-07-10 00:29:59 +03:00 committed by Andreas Kling
parent 08e88bfcad
commit 68980bf711

View file

@ -96,11 +96,11 @@ ErrorOr<FlatPtr> Process::sys$poll(Userspace<Syscall::SC_poll_params const*> use
if (fds_entry.unblocked_flags == BlockFlags::None) if (fds_entry.unblocked_flags == BlockFlags::None)
continue; continue;
if (has_any_flag(fds_entry.unblocked_flags, BlockFlags::WriteError | BlockFlags::WriteHangUp) || !fds_entry.description) { if (has_flag(fds_entry.unblocked_flags, BlockFlags::WriteHangUp))
pfd.revents |= POLLHUP;
if (has_flag(fds_entry.unblocked_flags, BlockFlags::WriteError) || !fds_entry.description) {
if (has_flag(fds_entry.unblocked_flags, BlockFlags::WriteError)) if (has_flag(fds_entry.unblocked_flags, BlockFlags::WriteError))
pfd.revents |= POLLERR; pfd.revents |= POLLERR;
if (has_flag(fds_entry.unblocked_flags, BlockFlags::WriteHangUp))
pfd.revents |= POLLHUP;
if (!fds_entry.description) if (!fds_entry.description)
pfd.revents |= POLLNVAL; pfd.revents |= POLLNVAL;
} else { } else {
@ -112,7 +112,7 @@ ErrorOr<FlatPtr> Process::sys$poll(Userspace<Syscall::SC_poll_params const*> use
VERIFY(pfd.events & POLLPRI); VERIFY(pfd.events & POLLPRI);
pfd.revents |= POLLPRI; pfd.revents |= POLLPRI;
} }
if (has_flag(fds_entry.unblocked_flags, BlockFlags::Write)) { if (!has_flag(fds_entry.unblocked_flags, BlockFlags::WriteHangUp) && has_flag(fds_entry.unblocked_flags, BlockFlags::Write)) {
VERIFY(pfd.events & POLLOUT); VERIFY(pfd.events & POLLOUT);
pfd.revents |= POLLOUT; pfd.revents |= POLLOUT;
} }