mirror of
https://github.com/RGBCube/serenity
synced 2025-07-22 21:57:35 +00:00
Kernel: Don't hog file descriptor table lock in sys$bind()
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
85ceab1fec
commit
e103c5fe2d
1 changed files with 7 additions and 9 deletions
|
@ -51,15 +51,13 @@ ErrorOr<FlatPtr> Process::sys$socket(int domain, int type, int protocol)
|
||||||
ErrorOr<FlatPtr> Process::sys$bind(int sockfd, Userspace<sockaddr const*> address, socklen_t address_length)
|
ErrorOr<FlatPtr> Process::sys$bind(int sockfd, Userspace<sockaddr const*> address, socklen_t address_length)
|
||||||
{
|
{
|
||||||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
||||||
return m_fds.with_exclusive([&](auto& fds) -> ErrorOr<FlatPtr> {
|
auto description = TRY(open_file_description(sockfd));
|
||||||
auto description = TRY(fds.open_file_description(sockfd));
|
|
||||||
if (!description->is_socket())
|
if (!description->is_socket())
|
||||||
return ENOTSOCK;
|
return ENOTSOCK;
|
||||||
auto& socket = *description->socket();
|
auto& socket = *description->socket();
|
||||||
REQUIRE_PROMISE_FOR_SOCKET_DOMAIN(socket.domain());
|
REQUIRE_PROMISE_FOR_SOCKET_DOMAIN(socket.domain());
|
||||||
TRY(socket.bind(address, address_length));
|
TRY(socket.bind(address, address_length));
|
||||||
return 0;
|
return 0;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<FlatPtr> Process::sys$listen(int sockfd, int backlog)
|
ErrorOr<FlatPtr> Process::sys$listen(int sockfd, int backlog)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue