mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:17:44 +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
|
@ -169,7 +169,7 @@ private:
|
|||
#ifdef AK_OS_SERENITY
|
||||
m_socket->on_ready_to_read = [this] {
|
||||
u32 length;
|
||||
auto maybe_bytes_read = m_socket->read({ (u8*)&length, sizeof(length) });
|
||||
auto maybe_bytes_read = m_socket->read_some({ (u8*)&length, sizeof(length) });
|
||||
if (maybe_bytes_read.is_error()) {
|
||||
dbgln("InspectorServerConnection: Failed to read message length from inspector server connection: {}", maybe_bytes_read.error());
|
||||
shutdown();
|
||||
|
@ -186,7 +186,7 @@ private:
|
|||
VERIFY(bytes_read.size() == sizeof(length));
|
||||
|
||||
auto request_buffer = ByteBuffer::create_uninitialized(length).release_value();
|
||||
maybe_bytes_read = m_socket->read(request_buffer.bytes());
|
||||
maybe_bytes_read = m_socket->read_some(request_buffer.bytes());
|
||||
if (maybe_bytes_read.is_error()) {
|
||||
dbgln("InspectorServerConnection: Failed to read message content from inspector server connection: {}", maybe_bytes_read.error());
|
||||
shutdown();
|
||||
|
@ -221,10 +221,11 @@ public:
|
|||
auto bytes_to_send = serialized.bytes();
|
||||
u32 length = bytes_to_send.size();
|
||||
// FIXME: Propagate errors
|
||||
auto sent = MUST(m_socket->write({ (u8 const*)&length, sizeof(length) }));
|
||||
// FIXME: This should write the entire span.
|
||||
auto sent = MUST(m_socket->write_some({ (u8 const*)&length, sizeof(length) }));
|
||||
VERIFY(sent == sizeof(length));
|
||||
while (!bytes_to_send.is_empty()) {
|
||||
size_t bytes_sent = MUST(m_socket->write(bytes_to_send));
|
||||
size_t bytes_sent = MUST(m_socket->write_some(bytes_to_send));
|
||||
bytes_to_send = bytes_to_send.slice(bytes_sent);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue