mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:08:12 +00:00
Kernel: Return the correct result for FIONREAD on datagram sockets
Before this commit, we only checked the receive buffer on the socket, which is unused on datagram streams. Now we return the actual size of the datagram without the protocol headers, which required the protocol to tell us what the size of the payload is.
This commit is contained in:
parent
e4a1bc1542
commit
3da0c072f4
6 changed files with 26 additions and 1 deletions
|
@ -774,7 +774,15 @@ ErrorOr<void> IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac
|
|||
return ioctl_arp();
|
||||
|
||||
case FIONREAD: {
|
||||
int readable = m_receive_buffer->immediately_readable();
|
||||
int readable = 0;
|
||||
if (buffer_mode() == BufferMode::Bytes) {
|
||||
readable = static_cast<int>(m_receive_buffer->immediately_readable());
|
||||
} else {
|
||||
if (m_receive_queue.size() != 0u) {
|
||||
readable = static_cast<int>(TRY(protocol_size(m_receive_queue.first().data->bytes())));
|
||||
}
|
||||
}
|
||||
|
||||
return copy_to_user(static_ptr_cast<int*>(arg), &readable);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue