mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:38:10 +00:00
IPv4: Disconnected non-blocking sockets were not signalling EOF
After a socket has disconnected, we shouldn't return -EAGAIN. Instead we should allow userspace to read/recvfrom the socket until its packet queue has been exhausted. At that point, we now return 0, signalling EOF. It might be even better to start returning -ENOTCONN after signalling EOF once. I'm not sure how that should work, needs looking into.
This commit is contained in:
parent
b7a840fd0d
commit
0e9e70ca4f
1 changed files with 8 additions and 2 deletions
|
@ -222,8 +222,14 @@ ssize_t IPv4Socket::recvfrom(FileDescription& description, void* buffer, size_t
|
|||
ReceivedPacket packet;
|
||||
{
|
||||
LOCKER(lock());
|
||||
if (m_receive_queue.is_empty() && !description.is_blocking())
|
||||
return -EAGAIN;
|
||||
if (m_receive_queue.is_empty()) {
|
||||
// FIXME: Shouldn't this return -ENOTCONN instead of EOF?
|
||||
// But if so, we still need to deliver at least one EOF read to userspace.. right?
|
||||
if (protocol_is_disconnected())
|
||||
return 0;
|
||||
if (!description.is_blocking())
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
if (!m_receive_queue.is_empty()) {
|
||||
packet = m_receive_queue.take_first();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue