From 69debf9e84bfa0cec33bc1e3e89b1d074ae95784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 8 Jun 2004 05:58:23 +0000 Subject: [PATCH] get_module() didn't correctly maintain the module ref_count (in case something went wrong) - this would have hidden circular dependencies as well. Recursive directory scan was broken, it didn't filter "." and ".." out. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7829 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/module.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/kernel/core/module.c b/src/kernel/core/module.c index a90b1b782a..a9938799c7 100644 --- a/src/kernel/core/module.c +++ b/src/kernel/core/module.c @@ -48,7 +48,7 @@ static module_info *sBuiltInModules[] = { NULL }; -#define TRACE_MODULE +//#define TRACE_MODULE #ifdef TRACE_MODULE # define TRACE(x) dprintf x #else @@ -494,6 +494,9 @@ recurse_directory(const char *path, const char *searchedName) goto exit; } + if (!strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, "..")) + continue; + size = strlen(path) + strlen(dirent->d_name) + 2; newPath = (char *)malloc(size); if (newPath == NULL) { @@ -1273,20 +1276,19 @@ get_module(const char *path, module_info **_info) module->module_image->keep_loaded = true; } - inc_module_ref_count(module); - // The state will be adjusted by the call to init_module // if we have just loaded the file - if (module->ref_count == 1) + if (module->ref_count == 0) status = init_module(module); else status = B_OK; - recursive_lock_unlock(&sModulesLock); - - if (status == B_OK) + if (status == B_OK) { + inc_module_ref_count(module); *_info = module->info; + } + recursive_lock_unlock(&sModulesLock); return status; err: