From 757031348ecf921b4ff47cae710b57e49e98ec18 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 27 May 2024 19:38:34 -0400 Subject: [PATCH] network/stack: Unload all modules at end of scan process. Otherwise, modules that depend on each other will be repeatedly loaded and unloaded. This reduces the number of register_domain() calls on a standard boot (of @minimum, at least) from 43 to 31. --- src/add-ons/kernel/network/stack/stack.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/add-ons/kernel/network/stack/stack.cpp b/src/add-ons/kernel/network/stack/stack.cpp index a784827b69..1efd538432 100644 --- a/src/add-ons/kernel/network/stack/stack.cpp +++ b/src/add-ons/kernel/network/stack/stack.cpp @@ -22,6 +22,7 @@ #include #include +#include #include @@ -743,6 +744,7 @@ scan_modules(const char* path) if (cookie == NULL) return; + Vector modules; while (true) { char name[B_FILE_NAME_LENGTH]; size_t length = sizeof(name); @@ -751,15 +753,19 @@ scan_modules(const char* path) TRACE(("scan %s\n", name)); + // we don't need the module right now, but we give it a chance + // to register itself module_info* module; - if (get_module(name, &module) == B_OK) { - // we don't need the module right now, but we give it a chance - // to register itself - put_module(name); - } + if (get_module(name, &module) == B_OK) + modules.Add(module); } close_module_list(cookie); + + // We don't need the modules right now, so put them all. + // (This is done at the end to avoid repeated loading/unloading of dependencies.) + for (int32 i = 0; i < modules.Count(); i++) + put_module(modules[i]->name); }