LibCore: Use Core::System::poll()
in PosixSocketHelper
This commit is contained in:
parent
5532640b71
commit
3750687821
Notes:
sideshowbarker
2024-07-17 05:02:35 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/3750687821 Pull-request: https://github.com/SerenityOS/serenity/pull/16439 Reviewed-by: https://github.com/timschumi ✅
1 changed files with 5 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue