diff --git a/C/services/common/include/binary_plugin_handle.h b/C/services/common/include/binary_plugin_handle.h index 481819b7ec..e690621a68 100644 --- a/C/services/common/include/binary_plugin_handle.h +++ b/C/services/common/include/binary_plugin_handle.h @@ -13,6 +13,7 @@ #include #include #include +#include /** * The BinaryPluginHandle class is used to represent an interface to @@ -21,13 +22,27 @@ class BinaryPluginHandle : public PluginHandle { public: - BinaryPluginHandle(const char *, const char *path) { handle = dlopen(path, RTLD_LAZY|RTLD_GLOBAL); } + // for the Storage plugin + BinaryPluginHandle(const char *name, const char *path, tPluginType type) { + handle = dlopen(path, RTLD_LAZY); + + Logger::getLogger()->debug("%s - storage plugin / RTLD_LAZY - name :%s: path :%s:", __FUNCTION__, name, path); + } + + // for all the others plugins + BinaryPluginHandle(const char *name, const char *path) { + handle = dlopen(path, RTLD_LAZY|RTLD_GLOBAL); + + Logger::getLogger()->debug("%s - other plugin / RTLD_LAZY|RTLD_GLOBAL - name :%s: path :%s:", __FUNCTION__, name, path); + } + ~BinaryPluginHandle() { if (handle) dlclose(handle); } void *GetInfo() { return dlsym(handle, "plugin_info"); } void *ResolveSymbol(const char* sym) { return dlsym(handle, sym); } void *getHandle() { return handle; } private: PLUGIN_HANDLE handle; // pointer returned by dlopen on plugin shared lib + }; #endif diff --git a/C/services/common/include/plugin_manager.h b/C/services/common/include/plugin_manager.h index b0b4c7b770..609dcb75b0 100644 --- a/C/services/common/include/plugin_manager.h +++ b/C/services/common/include/plugin_manager.h @@ -17,6 +17,12 @@ #include #include +typedef enum PluginType +{ + PLUGIN_TYPE_ID_STORAGE, + PLUGIN_TYPE_ID_OTHER +} tPluginType; + /** * The manager for plugins. * @@ -37,6 +43,7 @@ class PluginManager { *getInfo(const PLUGIN_HANDLE); void getInstalledPlugins(const std::string& type, std::list& plugins); + void setPluginType(tPluginType type); public: static PluginManager* instance; @@ -53,6 +60,7 @@ class PluginManager { std::map pluginHandleMap; Logger* logger; + tPluginType m_pluginType; }; #endif diff --git a/C/services/common/plugin_manager.cpp b/C/services/common/plugin_manager.cpp index a443136392..493c93033d 100644 --- a/C/services/common/plugin_manager.cpp +++ b/C/services/common/plugin_manager.cpp @@ -52,6 +52,8 @@ PluginManager *PluginManager::getInstance() PluginManager::PluginManager() { logger = Logger::getLogger(); + + m_pluginType = PLUGIN_TYPE_ID_OTHER; } enum PLUGIN_TYPE { @@ -248,6 +250,13 @@ string findPlugin(string name, string _type, string _plugin_path, PLUGIN_TYPE ty return ""; } +/** + * Set Plugin Type + */ +void PluginManager::setPluginType(tPluginType type) { + m_pluginType = type; +} + /** * Load a given plugin */ @@ -343,7 +352,14 @@ char buf[MAXPATHLEN]; strncpy(buf, path.c_str(), sizeof(buf)); if (buf[0] && access(buf, F_OK|R_OK) == 0) { - pluginHandle = new BinaryPluginHandle(name.c_str(), buf); + if (m_pluginType == PLUGIN_TYPE_ID_STORAGE) + { + pluginHandle = new BinaryPluginHandle(name.c_str(), buf, PLUGIN_TYPE_ID_STORAGE); + } else + { + pluginHandle = new BinaryPluginHandle(name.c_str(), buf); + } + hndl = pluginHandle->getHandle(); if (hndl != NULL) { diff --git a/C/services/storage/storage.cpp b/C/services/storage/storage.cpp index 6945113053..104acc249d 100644 --- a/C/services/storage/storage.cpp +++ b/C/services/storage/storage.cpp @@ -379,6 +379,7 @@ void StorageService::stop() bool StorageService::loadPlugin() { PluginManager *manager = PluginManager::getInstance(); + manager->setPluginType(PLUGIN_TYPE_ID_STORAGE); const char *plugin = config->getValue("plugin"); if (plugin == NULL)