mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:07:34 +00:00
LibCore+LibIPC: Make Core::Stream read_without_waiting() return Bytes
For the reasoning, see the earlier commit about Core::Stream::read().
This commit is contained in:
parent
d564cf1e89
commit
fe5fdb200b
3 changed files with 9 additions and 9 deletions
|
@ -552,9 +552,9 @@ ErrorOr<pid_t> LocalSocket::peer_pid() const
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<size_t> LocalSocket::read_without_waiting(Bytes buffer)
|
ErrorOr<Bytes> LocalSocket::read_without_waiting(Bytes buffer)
|
||||||
{
|
{
|
||||||
return TRY(m_helper.read(buffer, MSG_DONTWAIT)).size();
|
return m_helper.read(buffer, MSG_DONTWAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<int> LocalSocket::release_fd()
|
ErrorOr<int> LocalSocket::release_fd()
|
||||||
|
|
|
@ -444,7 +444,7 @@ public:
|
||||||
ErrorOr<int> receive_fd(int flags);
|
ErrorOr<int> receive_fd(int flags);
|
||||||
ErrorOr<void> send_fd(int fd);
|
ErrorOr<void> send_fd(int fd);
|
||||||
ErrorOr<pid_t> peer_pid() const;
|
ErrorOr<pid_t> peer_pid() const;
|
||||||
ErrorOr<size_t> read_without_waiting(Bytes buffer);
|
ErrorOr<Bytes> read_without_waiting(Bytes buffer);
|
||||||
|
|
||||||
/// Release the fd associated with this LocalSocket. After the fd is
|
/// Release the fd associated with this LocalSocket. After the fd is
|
||||||
/// released, the socket will be considered "closed" and all operations done
|
/// released, the socket will be considered "closed" and all operations done
|
||||||
|
|
|
@ -121,9 +121,9 @@ ErrorOr<Vector<u8>> ConnectionBase::read_as_much_as_possible_from_socket_without
|
||||||
|
|
||||||
u8 buffer[4096];
|
u8 buffer[4096];
|
||||||
while (m_socket->is_open()) {
|
while (m_socket->is_open()) {
|
||||||
auto maybe_nread = m_socket->read_without_waiting({ buffer, 4096 });
|
auto maybe_bytes_read = m_socket->read_without_waiting({ buffer, 4096 });
|
||||||
if (maybe_nread.is_error()) {
|
if (maybe_bytes_read.is_error()) {
|
||||||
auto error = maybe_nread.release_error();
|
auto error = maybe_bytes_read.release_error();
|
||||||
if (error.is_syscall() && error.code() == EAGAIN) {
|
if (error.is_syscall() && error.code() == EAGAIN) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -133,13 +133,13 @@ ErrorOr<Vector<u8>> ConnectionBase::read_as_much_as_possible_from_socket_without
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto nread = maybe_nread.release_value();
|
auto bytes_read = maybe_bytes_read.release_value();
|
||||||
if (nread == 0) {
|
if (bytes_read.is_empty()) {
|
||||||
deferred_invoke([this] { shutdown(); });
|
deferred_invoke([this] { shutdown(); });
|
||||||
return Error::from_string_literal("IPC connection EOF"sv);
|
return Error::from_string_literal("IPC connection EOF"sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes.append(buffer, nread);
|
bytes.append(bytes_read.data(), bytes_read.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bytes.is_empty()) {
|
if (!bytes.is_empty()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue