From 2008ccc79e21962ffb5e327c2aba4ea7c8da76a1 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 2 Jul 2009 08:45:10 +0200 Subject: =?UTF-8?q?Module=20k=C3=B6nnen=20wieder=20statisch=20gelinkt=20we?= =?UTF-8?q?rden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/ModuleManager.cpp | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'src/Common/ModuleManager.cpp') diff --git a/src/Common/ModuleManager.cpp b/src/Common/ModuleManager.cpp index 74c424d..67a1b14 100644 --- a/src/Common/ModuleManager.cpp +++ b/src/Common/ModuleManager.cpp @@ -26,12 +26,16 @@ #include #include +#include + #include namespace Mad { namespace Common { +const ModuleManager::ModuleHandle ModuleManager::STATIC_MODULE = 0; + ModuleManager::ModuleManager(Application *application0) : application(application0) { application->getConfigManager()->registerConfigurable(this); } @@ -73,26 +77,31 @@ bool ModuleManager::loadModule(const std::string &name) { return true; } - ModuleHandle handle = dlopen((name + MODULE_SUFFIX).c_str(), RTLD_NOW | RTLD_GLOBAL); + ModuleHandle handle = STATIC_MODULE; + Module *mod = Modules::loadStaticModule(application, name); - if(!handle) { - application->log(Core::LoggerBase::VERBOSE, std::string("loadModule: Can't open module: ") + std::string(dlerror())); - return false; - } + if(!mod) { + handle = dlopen((name + MODULE_SUFFIX).c_str(), RTLD_NOW | RTLD_GLOBAL); - ModuleLoadFunc loader; - *(void**)&loader = dlsym(handle, (name + "_create").c_str()); + if(!handle) { + application->log(Core::LoggerBase::VERBOSE, std::string("loadModule: Can't open module: ") + std::string(dlerror())); + return false; + } - if(!loader) { - application->log(Core::LoggerBase::VERBOSE, "loadModule: Can't open module: Invalid module"); - return false; - } + ModuleLoadFunc loader; + *(void**)&loader = dlsym(handle, (name + "_create").c_str()); - Module *mod = loader(application); + if(!loader) { + application->log(Core::LoggerBase::VERBOSE, "loadModule: Can't open module: Invalid module"); + return false; + } - if(!mod) { - application->log(Core::LoggerBase::VERBOSE, "loadModule: Can't open module: Internal module error"); - return false; + Module *mod = loader(application); + + if(!mod) { + application->log(Core::LoggerBase::VERBOSE, "loadModule: Can't open module: Internal module error"); + return false; + } } modules.insert(std::make_pair(name, std::make_pair(handle, mod))).first; @@ -111,7 +120,9 @@ void ModuleManager::unloadModule(const std::string &name) { boost::upgrade_to_unique_lock upgradeLock(lock); delete mod->second.second; - dlclose(mod->second.first); + + if(mod->second.first != STATIC_MODULE) + dlclose(mod->second.first); modules.erase(mod); } -- cgit v1.2.3