summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-04-03 22:18:57 +0200
committerAndreas Kling <kling@serenityos.org>2022-04-03 22:18:57 +0200
commit85ceab1fec1aa5b8c0475c6314274e16ea57389a (patch)
treecfbdfe6b34bea3b86b0cd682459519a54bbb7798 /Kernel/Syscalls
parentbc4282c773cf04d981aebde36e3cab4efefe2e7a (diff)
downloadserenity-85ceab1fec1aa5b8c0475c6314274e16ea57389a.zip
Kernel: Don't hog file descriptor table lock in sys$listen()
We don't need to hold the lock across the entire syscall. Once we've fetched the open file description we're interested in, we can let go.
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r--Kernel/Syscalls/socket.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/Kernel/Syscalls/socket.cpp b/Kernel/Syscalls/socket.cpp
index 8811c37571..4f3b0f0286 100644
--- a/Kernel/Syscalls/socket.cpp
+++ b/Kernel/Syscalls/socket.cpp
@@ -67,17 +67,15 @@ ErrorOr<FlatPtr> Process::sys$listen(int sockfd, int backlog)
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
if (backlog < 0)
return EINVAL;
- return m_fds.with_exclusive([&](auto& fds) -> ErrorOr<FlatPtr> {
- auto description = TRY(fds.open_file_description(sockfd));
- if (!description->is_socket())
- return ENOTSOCK;
- auto& socket = *description->socket();
- REQUIRE_PROMISE_FOR_SOCKET_DOMAIN(socket.domain());
- if (socket.is_connected())
- return EINVAL;
- TRY(socket.listen(backlog));
- return 0;
- });
+ auto description = TRY(open_file_description(sockfd));
+ if (!description->is_socket())
+ return ENOTSOCK;
+ auto& socket = *description->socket();
+ REQUIRE_PROMISE_FOR_SOCKET_DOMAIN(socket.domain());
+ if (socket.is_connected())
+ return EINVAL;
+ TRY(socket.listen(backlog));
+ return 0;
}
ErrorOr<FlatPtr> Process::sys$accept4(Userspace<Syscall::SC_accept4_params const*> user_params)