mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
Kernel: Only lock process file descriptor table once in sys$poll()
Grab the OpenFileDescriptions mutex once and hold on to it while populating the SelectBlocker::FDVector.
This commit is contained in:
parent
b56646e293
commit
d748a3c173
1 changed files with 17 additions and 14 deletions
|
@ -47,9 +47,10 @@ ErrorOr<FlatPtr> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> use
|
|||
Thread::SelectBlocker::FDVector fds_info;
|
||||
TRY(fds_info.try_ensure_capacity(params.nfds));
|
||||
|
||||
TRY(m_fds.with_shared([&](auto& fds) -> ErrorOr<void> {
|
||||
for (size_t i = 0; i < params.nfds; i++) {
|
||||
auto& pfd = fds_copy[i];
|
||||
auto description = TRY(m_fds.with_shared([&](auto& fds) { return fds.open_file_description(pfd.fd); }));
|
||||
auto description = TRY(fds.open_file_description(pfd.fd));
|
||||
BlockFlags block_flags = BlockFlags::Exception; // always want POLLERR, POLLHUP, POLLNVAL
|
||||
if (pfd.events & POLLIN)
|
||||
block_flags |= BlockFlags::Read;
|
||||
|
@ -61,6 +62,8 @@ ErrorOr<FlatPtr> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> use
|
|||
block_flags |= BlockFlags::WritePriority;
|
||||
fds_info.unchecked_append({ move(description), block_flags });
|
||||
}
|
||||
return {};
|
||||
}));
|
||||
|
||||
auto* current_thread = Thread::current();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue