mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
LibCore: Use Core::System::poll()
in PosixSocketHelper
This commit is contained in:
parent
5532640b71
commit
3750687821
1 changed files with 5 additions and 8 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue