mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 01:59:14 +03: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
Notes:
sideshowbarker
2024-07-19 12:39:54 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/910fab564e1
@ -234,16 +234,24 @@ ssize_t LocalSocket::recvfrom(FileDescription& description, void* buffer, size_t
|
||||
auto role = this->role(description);
|
||||
if (role == Role::Accepted) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
ASSERT(!m_for_server.is_empty());
|
||||
return m_for_server.read((u8*)buffer, buffer_size);
|
||||
}
|
||||
if (role == Role::Connected) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
ASSERT(!m_for_client.is_empty());
|
||||
return m_for_client.read((u8*)buffer, buffer_size);
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
|
Loading…
Reference in New Issue
Block a user