From 37506878219b13160a64b87dfbb4aac8d3063fa1 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Sun, 11 Dec 2022 23:44:08 +0100 Subject: [PATCH] LibCore: Use `Core::System::poll()` in `PosixSocketHelper` --- Userland/Libraries/LibCore/Stream.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibCore/Stream.cpp b/Userland/Libraries/LibCore/Stream.cpp index 96216e2c07..bae56c00c5 100644 --- a/Userland/Libraries/LibCore/Stream.cpp +++ b/Userland/Libraries/LibCore/Stream.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -461,15 +460,13 @@ ErrorOr PosixSocketHelper::can_read_without_blocking(int timeout) const { struct pollfd the_fd = { .fd = m_fd, .events = POLLIN, .revents = 0 }; - // FIXME: Convert this to Core::System - int rc; + ErrorOr result { 0 }; do { - rc = ::poll(&the_fd, 1, timeout); - } while (rc < 0 && errno == EINTR); + result = Core::System::poll({ &the_fd, 1 }, timeout); + } while (result.is_error() && result.error().code() == EINTR); - if (rc < 0) { - return Error::from_syscall("poll"sv, -errno); - } + if (result.is_error()) + return result.release_error(); return (the_fd.revents & POLLIN) > 0; }