mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:47:45 +00: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,20 +47,23 @@ ErrorOr<FlatPtr> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> use
|
||||||
Thread::SelectBlocker::FDVector fds_info;
|
Thread::SelectBlocker::FDVector fds_info;
|
||||||
TRY(fds_info.try_ensure_capacity(params.nfds));
|
TRY(fds_info.try_ensure_capacity(params.nfds));
|
||||||
|
|
||||||
for (size_t i = 0; i < params.nfds; i++) {
|
TRY(m_fds.with_shared([&](auto& fds) -> ErrorOr<void> {
|
||||||
auto& pfd = fds_copy[i];
|
for (size_t i = 0; i < params.nfds; i++) {
|
||||||
auto description = TRY(m_fds.with_shared([&](auto& fds) { return fds.open_file_description(pfd.fd); }));
|
auto& pfd = fds_copy[i];
|
||||||
BlockFlags block_flags = BlockFlags::Exception; // always want POLLERR, POLLHUP, POLLNVAL
|
auto description = TRY(fds.open_file_description(pfd.fd));
|
||||||
if (pfd.events & POLLIN)
|
BlockFlags block_flags = BlockFlags::Exception; // always want POLLERR, POLLHUP, POLLNVAL
|
||||||
block_flags |= BlockFlags::Read;
|
if (pfd.events & POLLIN)
|
||||||
if (pfd.events & POLLOUT)
|
block_flags |= BlockFlags::Read;
|
||||||
block_flags |= BlockFlags::Write;
|
if (pfd.events & POLLOUT)
|
||||||
if (pfd.events & POLLPRI)
|
block_flags |= BlockFlags::Write;
|
||||||
block_flags |= BlockFlags::ReadPriority;
|
if (pfd.events & POLLPRI)
|
||||||
if (pfd.events & POLLWRBAND)
|
block_flags |= BlockFlags::ReadPriority;
|
||||||
block_flags |= BlockFlags::WritePriority;
|
if (pfd.events & POLLWRBAND)
|
||||||
fds_info.unchecked_append({ move(description), block_flags });
|
block_flags |= BlockFlags::WritePriority;
|
||||||
}
|
fds_info.unchecked_append({ move(description), block_flags });
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}));
|
||||||
|
|
||||||
auto* current_thread = Thread::current();
|
auto* current_thread = Thread::current();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue