mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:27:34 +00:00
LocalSocket: Make recvfrom() return 0 to signal EOF when peer is gone
Once the peer has disconnected, recvfrom() should always return 0 once the socket buffer has been drained.
This commit is contained in:
parent
17670ae725
commit
910fab564e
1 changed files with 10 additions and 2 deletions
|
@ -234,16 +234,24 @@ ssize_t LocalSocket::recvfrom(FileDescription& description, void* buffer, size_t
|
||||||
auto role = this->role(description);
|
auto role = this->role(description);
|
||||||
if (role == Role::Accepted) {
|
if (role == Role::Accepted) {
|
||||||
if (!description.is_blocking()) {
|
if (!description.is_blocking()) {
|
||||||
if (m_for_server.is_empty())
|
if (m_for_server.is_empty()) {
|
||||||
|
if (!has_attached_peer(description))
|
||||||
|
return 0;
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
ASSERT(!m_for_server.is_empty());
|
||||||
return m_for_server.read((u8*)buffer, buffer_size);
|
return m_for_server.read((u8*)buffer, buffer_size);
|
||||||
}
|
}
|
||||||
if (role == Role::Connected) {
|
if (role == Role::Connected) {
|
||||||
if (!description.is_blocking()) {
|
if (!description.is_blocking()) {
|
||||||
if (m_for_client.is_empty())
|
if (m_for_client.is_empty()) {
|
||||||
|
if (!has_attached_peer(description))
|
||||||
|
return 0;
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
ASSERT(!m_for_client.is_empty());
|
||||||
return m_for_client.read((u8*)buffer, buffer_size);
|
return m_for_client.read((u8*)buffer, buffer_size);
|
||||||
}
|
}
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue