mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 16:15:10 +00:00
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.
This commit is contained in:
parent
bc4282c773
commit
85ceab1fec
1 changed files with 9 additions and 11 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue