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
This commit is contained in:
Axel Dörfler
2004-06-08 05:58:23 +00:00
parent 39f34cf425
commit 69debf9e84
+9 -7
View File
@@ -48,7 +48,7 @@ static module_info *sBuiltInModules[] = {
NULL NULL
}; };
#define TRACE_MODULE //#define TRACE_MODULE
#ifdef TRACE_MODULE #ifdef TRACE_MODULE
# define TRACE(x) dprintf x # define TRACE(x) dprintf x
#else #else
@@ -494,6 +494,9 @@ recurse_directory(const char *path, const char *searchedName)
goto exit; goto exit;
} }
if (!strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, ".."))
continue;
size = strlen(path) + strlen(dirent->d_name) + 2; size = strlen(path) + strlen(dirent->d_name) + 2;
newPath = (char *)malloc(size); newPath = (char *)malloc(size);
if (newPath == NULL) { if (newPath == NULL) {
@@ -1273,20 +1276,19 @@ get_module(const char *path, module_info **_info)
module->module_image->keep_loaded = true; module->module_image->keep_loaded = true;
} }
inc_module_ref_count(module);
// The state will be adjusted by the call to init_module // The state will be adjusted by the call to init_module
// if we have just loaded the file // if we have just loaded the file
if (module->ref_count == 1) if (module->ref_count == 0)
status = init_module(module); status = init_module(module);
else else
status = B_OK; status = B_OK;
recursive_lock_unlock(&sModulesLock); if (status == B_OK) {
inc_module_ref_count(module);
if (status == B_OK)
*_info = module->info; *_info = module->info;
}
recursive_lock_unlock(&sModulesLock);
return status; return status;
err: err: