libc: propagate fd flags in socket_fs_plugin

When creating a socket, fd flags can be specified by ORing them with the
socket type. Most importantly, the flag SOCK_NONBLOCK must be propagated
to the Socket_fs::Context in order to support non-blocking recv/send.

genodelabs/genode#4550
This commit is contained in:
Johannes Schlatow 2022-06-28 17:11:46 +02:00 committed by Christian Helmuth
parent 7c340b1cc9
commit a8070a429a

View File

@ -1065,6 +1065,13 @@ extern "C" int socket_fs_socket(int domain, int type, int protocol)
Socket_fs::Context(proto, handle_fd);
} catch (New_socket_failed) { return Errno(ENFILE); }
if (context) {
int flags = 0;
if (type & SOCK_NONBLOCK) flags |= O_NONBLOCK;
if (type & SOCK_CLOEXEC) flags |= O_CLOEXEC;
context->fd_flags(flags);
}
File_descriptor *fd = file_descriptor_allocator()->alloc(&plugin(), context);
if (!fd) {
Libc::Allocator alloc { };