mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:48:12 +00:00
Kernel: Make sys$recvfrom() with MSG_DONTWAIT not so racy
Instead of temporary changing the open file description's "blocking" flag while doing a non-waiting recvfrom, we instead plumb the currently wanted blocking behavior all the way through to the underlying socket.
This commit is contained in:
parent
8997c6a4d1
commit
42435ce5e4
7 changed files with 17 additions and 22 deletions
|
@ -334,12 +334,12 @@ DoubleBuffer* LocalSocket::send_buffer_for(OpenFileDescription& description)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ErrorOr<size_t> LocalSocket::recvfrom(OpenFileDescription& description, UserOrKernelBuffer& buffer, size_t buffer_size, int, Userspace<sockaddr*>, Userspace<socklen_t*>, Time&)
|
||||
ErrorOr<size_t> LocalSocket::recvfrom(OpenFileDescription& description, UserOrKernelBuffer& buffer, size_t buffer_size, int, Userspace<sockaddr*>, Userspace<socklen_t*>, Time&, bool blocking)
|
||||
{
|
||||
auto* socket_buffer = receive_buffer_for(description);
|
||||
if (!socket_buffer)
|
||||
return set_so_error(EINVAL);
|
||||
if (!description.is_blocking()) {
|
||||
if (!blocking) {
|
||||
if (socket_buffer->is_empty()) {
|
||||
if (!has_attached_peer(description))
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue