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

LibCore: Use Core::System::poll() in PosixSocketHelper

This commit is contained in:
Lucas CHOLLET 2022-12-11 23:44:08 +01:00 committed by Sam Atkins
parent 5532640b71
commit 3750687821

View file

@ -9,7 +9,6 @@
#include <LibCore/System.h> #include <LibCore/System.h>
#include <fcntl.h> #include <fcntl.h>
#include <netdb.h> #include <netdb.h>
#include <poll.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
@ -461,15 +460,13 @@ ErrorOr<bool> PosixSocketHelper::can_read_without_blocking(int timeout) const
{ {
struct pollfd the_fd = { .fd = m_fd, .events = POLLIN, .revents = 0 }; struct pollfd the_fd = { .fd = m_fd, .events = POLLIN, .revents = 0 };
// FIXME: Convert this to Core::System ErrorOr<int> result { 0 };
int rc;
do { do {
rc = ::poll(&the_fd, 1, timeout); result = Core::System::poll({ &the_fd, 1 }, timeout);
} while (rc < 0 && errno == EINTR); } while (result.is_error() && result.error().code() == EINTR);
if (rc < 0) { if (result.is_error())
return Error::from_syscall("poll"sv, -errno); return result.release_error();
}
return (the_fd.revents & POLLIN) > 0; return (the_fd.revents & POLLIN) > 0;
} }