1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:07:35 +00:00

LibCore: Remove the barely-used Core::safe_syscall()

This was a helper that would call a syscall repeatedly until it either
succeeded or failed with a non-EINTR error.

It was only used in two places, so I don't think we need this helper.
This commit is contained in:
Andreas Kling 2021-04-21 20:05:00 +02:00
parent c41c41cc0f
commit e5318d51e6
4 changed files with 22 additions and 74 deletions

View file

@ -27,7 +27,6 @@
#include <AK/ByteBuffer.h>
#include <AK/PrintfImplementation.h>
#include <LibCore/IODevice.h>
#include <LibCore/SyscallUtils.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
@ -106,17 +105,21 @@ ByteBuffer IODevice::read(size_t max_size)
bool IODevice::can_read_from_fd() const
{
// FIXME: Can we somehow remove this once Core::Socket is implemented using non-blocking sockets?
fd_set rfds;
fd_set rfds {};
FD_ZERO(&rfds);
FD_SET(m_fd, &rfds);
struct timeval timeout {
0, 0
};
int rc = Core::safe_syscall(select, m_fd + 1, &rfds, nullptr, nullptr, &timeout);
if (rc < 0) {
// NOTE: We don't set m_error here.
perror("IODevice::can_read: select");
return false;
for (;;) {
if (select(m_fd + 1, &rfds, nullptr, nullptr, &timeout) < 0) {
if (errno == EINTR)
continue;
perror("IODevice::can_read_from_fd: select");
return false;
}
break;
}
return FD_ISSET(m_fd, &rfds);
}
@ -332,5 +335,4 @@ LineIterator& LineIterator::operator++()
m_buffer = m_device->read_line();
return *this;
}
}