1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:58:11 +00:00

Kernel: Don't copy a Vector<FileDescriptionAndFlags>

Instead of copying a Vector everytime we need to enumerate a Process'
file descriptions, we can just temporarily lock so it won't change.
This commit is contained in:
Liav A 2021-06-22 21:22:17 +03:00 committed by Andreas Kling
parent 12b6e69150
commit 7c87891c06
28 changed files with 198 additions and 128 deletions

View file

@ -573,15 +573,14 @@ KResult Process::do_exec(NonnullRefPtr<FileDescription> main_program_description
clear_futex_queues_on_exec();
for (size_t i = 0; i < m_fds.size(); ++i) {
auto& description_and_flags = m_fds[i];
if (description_and_flags.description() && description_and_flags.flags() & FD_CLOEXEC)
description_and_flags = {};
}
fds().change_each([&](auto& file_description_metadata) {
if (file_description_metadata.is_valid() && file_description_metadata.flags() & FD_CLOEXEC)
file_description_metadata = {};
});
int main_program_fd = -1;
if (interpreter_description) {
main_program_fd = alloc_fd();
main_program_fd = m_fds.allocate();
VERIFY(main_program_fd >= 0);
auto seek_result = main_program_description->seek(0, SEEK_SET);
VERIFY(!seek_result.is_error());