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

Kernel: Use non-locking {Nonnull,}RefPtr for OpenFileDescription

This patch switches away from {Nonnull,}LockRefPtr to the non-locking
smart pointers throughout the kernel.

I've looked at the handful of places where these were being persisted
and I don't see any race situations.

Note that the process file descriptor table (Process::m_fds) was already
guarded via MutexProtected.
This commit is contained in:
Andreas Kling 2023-03-06 19:29:25 +01:00
parent 36b0ecfe9e
commit d1371d66f7
34 changed files with 82 additions and 80 deletions

View file

@ -20,7 +20,7 @@ namespace Kernel {
TRY(require_promise(Pledge::unix)); \
} while (0)
static void setup_socket_fd(Process::OpenFileDescriptions& fds, int fd, NonnullLockRefPtr<OpenFileDescription> description, int type)
static void setup_socket_fd(Process::OpenFileDescriptions& fds, int fd, NonnullRefPtr<OpenFileDescription> description, int type)
{
description->set_readable(true);
description->set_writable(true);
@ -94,7 +94,7 @@ ErrorOr<FlatPtr> Process::sys$accept4(Userspace<Syscall::SC_accept4_params const
TRY(copy_from_user(&address_size, static_ptr_cast<socklen_t const*>(user_address_size)));
ScopedDescriptionAllocation fd_allocation;
LockRefPtr<OpenFileDescription> accepting_socket_description;
RefPtr<OpenFileDescription> accepting_socket_description;
TRY(m_fds.with_exclusive([&](auto& fds) -> ErrorOr<void> {
fd_allocation = TRY(fds.allocate());