1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

IPv4: Non-blocking IPv4 sockets should return -EAGAIN in recvfrom()

...if there are no packets in the receive queue.
This commit is contained in:
Andreas Kling 2019-11-04 13:41:36 +01:00
parent 43a6c70c2a
commit ecd23ce1a1

View file

@ -222,6 +222,9 @@ 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()) {
packet = m_receive_queue.take_first();
m_can_read = !m_receive_queue.is_empty();