mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
AK: Rename Stream::{read,write} to Stream::{read_some,write_some}
Similar to POSIX read, the basic read and write functions of AK::Stream do not have a lower limit of how much data they read or write (apart from "none at all"). Rename the functions to "read some [data]" and "write some [data]" (with "data" being omitted, since everything here is reading and writing data) to make them sufficiently distinct from the functions that ensure to use the entire buffer (which should be the go-to function for most usages). No functional changes, just a lot of new FIXMEs.
This commit is contained in:
parent
1d5b45f7d9
commit
d5871f5717
109 changed files with 474 additions and 329 deletions
|
@ -27,7 +27,8 @@ InspectableProcess::InspectableProcess(pid_t pid, NonnullOwnPtr<Core::LocalSocke
|
|||
|
||||
m_socket->on_ready_to_read = [this] {
|
||||
char c;
|
||||
[[maybe_unused]] auto buffer = m_socket->read({ &c, 1 });
|
||||
// FIXME: This should read the entire span.
|
||||
[[maybe_unused]] auto buffer = m_socket->read_some({ &c, 1 });
|
||||
if (m_socket->is_eof()) {
|
||||
Core::deferred_invoke([pid = this->m_pid] { g_processes.remove(pid); });
|
||||
return;
|
||||
|
@ -44,7 +45,8 @@ DeprecatedString InspectableProcess::wait_for_response()
|
|||
}
|
||||
|
||||
u32 length {};
|
||||
auto length_bytes_read = m_socket->read({ (u8*)&length, sizeof(length) }).release_value_but_fixme_should_propagate_errors();
|
||||
// FIXME: This should read the entire span.
|
||||
auto length_bytes_read = m_socket->read_some({ (u8*)&length, sizeof(length) }).release_value_but_fixme_should_propagate_errors();
|
||||
if (length_bytes_read.size() != sizeof(length)) {
|
||||
dbgln("InspectableProcess got malformed data: PID {}", m_pid);
|
||||
m_socket->close();
|
||||
|
@ -55,7 +57,7 @@ DeprecatedString InspectableProcess::wait_for_response()
|
|||
auto remaining_data_buffer = data_buffer.bytes();
|
||||
|
||||
while (!remaining_data_buffer.is_empty()) {
|
||||
auto maybe_bytes_read = m_socket->read(remaining_data_buffer);
|
||||
auto maybe_bytes_read = m_socket->read_some(remaining_data_buffer);
|
||||
if (maybe_bytes_read.is_error()) {
|
||||
dbgln("InspectableProcess::wait_for_response: Failed to read data: {}", maybe_bytes_read.error());
|
||||
break;
|
||||
|
@ -80,8 +82,9 @@ void InspectableProcess::send_request(JsonObject const& request)
|
|||
u32 length = serialized.length();
|
||||
|
||||
// FIXME: Propagate errors
|
||||
MUST(m_socket->write({ (u8 const*)&length, sizeof(length) }));
|
||||
MUST(m_socket->write(serialized.bytes()));
|
||||
// FIXME: This should write the entire span.
|
||||
MUST(m_socket->write_some({ (u8 const*)&length, sizeof(length) }));
|
||||
MUST(m_socket->write_some(serialized.bytes()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue