1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:18:12 +00:00

Kernel: Switch process file descriptor table from spinlock to mutex

There's no reason for this to use a spinlock. Instead, let's allow
threads to block if someone else is using the descriptor table.
This commit is contained in:
Andreas Kling 2022-01-29 01:29:07 +01:00
parent 8ebec2938c
commit b56646e293
16 changed files with 37 additions and 37 deletions

View file

@ -40,7 +40,7 @@ ErrorOr<FlatPtr> Process::sys$recvfd(int sockfd, int options)
if (!socket.is_local())
return EAFNOSUPPORT;
auto fd_allocation = TRY(m_fds.with([](auto& fds) { return fds.allocate(); }));
auto fd_allocation = TRY(m_fds.with_exclusive([](auto& fds) { return fds.allocate(); }));
auto& local_socket = static_cast<LocalSocket&>(socket);
auto received_description = TRY(local_socket.recvfd(*socket_description));
@ -49,7 +49,7 @@ ErrorOr<FlatPtr> Process::sys$recvfd(int sockfd, int options)
if (options & O_CLOEXEC)
fd_flags |= FD_CLOEXEC;
m_fds.with([&](auto& fds) { fds[fd_allocation.fd].set(move(received_description), fd_flags); });
m_fds.with_exclusive([&](auto& fds) { fds[fd_allocation.fd].set(move(received_description), fd_flags); });
return fd_allocation.fd;
}