From e6963ff534ccd9ae7e6de187039566e100470bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 12 Apr 2005 08:42:06 +0000 Subject: [PATCH] If B_KEEP_LOADED is specified, it's now guaranteed that B_MODULE_UNINIT is never called, and B_MODULE_INIT only once. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12342 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/module.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/kernel/core/module.c b/src/kernel/core/module.c index 196b4f6cdf..320bd28b9b 100644 --- a/src/kernel/core/module.c +++ b/src/kernel/core/module.c @@ -717,6 +717,8 @@ init_module(module *module) static inline int uninit_module(module *module) { + TRACE(("uninit_module(%s)\n", module->name)); + switch (module->state) { case MODULE_QUERIED: case MODULE_LOADED: @@ -1400,14 +1402,16 @@ put_module(const char *path) recursive_lock_unlock(&sModulesLock); return B_BAD_VALUE; } - dec_module_ref_count(module); + + if ((module->flags & B_KEEP_LOADED) == 0) { + dec_module_ref_count(module); - // ToDo: not sure if this should ever be called for keep_loaded modules... - if (module->ref_count == 0) - uninit_module(module); + if (module->ref_count == 0) + uninit_module(module); - if ((module->flags & B_BUILT_IN_MODULE) == 0) - put_module_image(module->module_image); + if ((module->flags & B_BUILT_IN_MODULE) == 0) + put_module_image(module->module_image); + } recursive_lock_unlock(&sModulesLock); return B_OK;