[Haiku-commits] r21476 - haiku/trunk/src/system/kernel
geist at BerliOS
geist at mail.berlios.de
Thu Jun 21 07:07:18 CEST 2007
Author: geist
Date: 2007-06-21 07:07:14 +0200 (Thu, 21 Jun 2007)
New Revision: 21476
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21476&view=rev
Modified:
haiku/trunk/src/system/kernel/module.cpp
Log:
Fix a bug that was tripping an assert in the kernel module code.
When iterating through modules, the iterator was loading the module file, inserting it into the module image hash. Then, the first time get_module() was called on a module contained in the image, it was trying to load the image again. It probably actually was. Changed the logic to call get_module_image() which checks to see if it's already loaded.
Modified: haiku/trunk/src/system/kernel/module.cpp
===================================================================
--- haiku/trunk/src/system/kernel/module.cpp 2007-06-20 21:58:02 UTC (rev 21475)
+++ haiku/trunk/src/system/kernel/module.cpp 2007-06-21 05:07:14 UTC (rev 21476)
@@ -359,16 +359,22 @@
TRACE(("get_module_image(path = \"%s\", _image = %p)\n", path, _image));
+ recursive_lock_lock(&sModulesLock);
+
image = (module_image *)hash_lookup(sModuleImagesHash, path);
if (image == NULL) {
status_t status = load_module_image(path, &image);
- if (status < B_OK)
+ if (status < B_OK) {
+ recursive_lock_unlock(&sModulesLock);
return status;
+ }
}
atomic_add(&image->ref_count, 1);
*_image = image;
+ recursive_lock_unlock(&sModulesLock);
+
return B_OK;
}
@@ -446,9 +452,8 @@
int index = 0, match = B_ENTRY_NOT_FOUND;
TRACE(("check_module_image(path = \"%s\", searchedName = \"%s\")\n", path, searchedName));
- ASSERT(hash_lookup(sModuleImagesHash, path) == NULL);
- if (load_module_image(path, &image) < B_OK)
+ if (get_module_image(path, &image) < B_OK)
return B_ENTRY_NOT_FOUND;
for (info = image->info; *info; info++) {
@@ -467,6 +472,9 @@
unload_module_image(image, path);
}
+ // decrement the ref we got in get_module_image
+ put_module_image(image);
+
return match;
}
More information about the Haiku-commits
mailing list