From 265764ff2fec038855193296588a887fc322d76a Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Thu, 2 Dec 2021 01:26:08 +0200 Subject: [PATCH] Kernel: Add support for the POLLWRBAND poll event --- Kernel/API/POSIX/poll.h | 1 + Kernel/Syscalls/select.cpp | 6 ++++++ Kernel/Thread.h | 13 +++++++------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Kernel/API/POSIX/poll.h b/Kernel/API/POSIX/poll.h index b5bd1d7d8c..c481ab61c7 100644 --- a/Kernel/API/POSIX/poll.h +++ b/Kernel/API/POSIX/poll.h @@ -20,6 +20,7 @@ extern "C" { #define POLLERR (1u << 3) #define POLLHUP (1u << 4) #define POLLNVAL (1u << 5) +#define POLLWRBAND (1u << 12) #define POLLRDHUP (1u << 13) struct pollfd { diff --git a/Kernel/Syscalls/select.cpp b/Kernel/Syscalls/select.cpp index 2800fa440b..af03a89b03 100644 --- a/Kernel/Syscalls/select.cpp +++ b/Kernel/Syscalls/select.cpp @@ -159,6 +159,8 @@ ErrorOr Process::sys$poll(Userspace use block_flags |= BlockFlags::Write; if (pfd.events & POLLPRI) block_flags |= BlockFlags::ReadPriority; + if (pfd.events & POLLWRBAND) + block_flags |= BlockFlags::WritePriority; TRY(fds_info.try_append({ move(description), block_flags })); } @@ -208,6 +210,10 @@ ErrorOr Process::sys$poll(Userspace use VERIFY(pfd.events & POLLOUT); pfd.revents |= POLLOUT; } + if (has_flag(fds_entry.unblocked_flags, BlockFlags::WritePriority)) { + VERIFY(pfd.events & POLLWRBAND); + pfd.revents |= POLLWRBAND; + } } if (pfd.revents) fds_with_revents++; diff --git a/Kernel/Thread.h b/Kernel/Thread.h index 4e50c27c3d..50a5a57032 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -588,15 +588,16 @@ public: Read = 1 << 0, Write = 1 << 1, ReadPriority = 1 << 2, + WritePriority = 1 << 3, - Accept = 1 << 3, - Connect = 1 << 4, + Accept = 1 << 4, + Connect = 1 << 5, SocketFlags = Accept | Connect, - WriteNotOpen = 1 << 5, - WriteError = 1 << 6, - WriteHangUp = 1 << 7, - ReadHangUp = 1 << 8, + WriteNotOpen = 1 << 6, + WriteError = 1 << 7, + WriteHangUp = 1 << 8, + ReadHangUp = 1 << 9, Exception = WriteNotOpen | WriteError | WriteHangUp | ReadHangUp, };