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
Notes: sideshowbarker 2024-07-17 05:02:35 +09:00

View file

@ -9,7 +9,6 @@
#include <LibCore/System.h>
#include <fcntl.h>
#include <netdb.h>
#include <poll.h>
#include <sys/ioctl.h>
#include <sys/socket.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 };
// FIXME: Convert this to Core::System
int rc;
ErrorOr<int> 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;
}