Added missing dlcolse to RsPluginManager::loadPlugin.

Added proper handling of the handle of the loaded plugin.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8465 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2015-06-15 15:15:18 +00:00
parent 6a778ab904
commit 9947a21c73
2 changed files with 17 additions and 0 deletions

View File

@ -186,6 +186,11 @@ void RsPluginManager::stopPlugins()
// delete _plugins[i].plugin; // delete _plugins[i].plugin;
// _plugins[i].plugin = NULL; // _plugins[i].plugin = NULL;
} }
if (_plugins[i].handle)
{
dlclose(_plugins[i].handle);
_plugins[i].handle = NULL;
}
} }
} }
@ -321,6 +326,7 @@ bool RsPluginManager::loadPlugin(const std::string& plugin_name)
std::cerr << " -> No API version number." << std::endl; std::cerr << " -> No API version number." << std::endl;
pinfo.status = PLUGIN_STATUS_MISSING_API ; pinfo.status = PLUGIN_STATUS_MISSING_API ;
pinfo.info_string = "" ; pinfo.info_string = "" ;
dlclose(handle);
return false ; return false ;
} }
if(pinfo.svn_revision == 0) if(pinfo.svn_revision == 0)
@ -328,6 +334,7 @@ bool RsPluginManager::loadPlugin(const std::string& plugin_name)
std::cerr << " -> No svn revision number." << std::endl; std::cerr << " -> No svn revision number." << std::endl;
pinfo.status = PLUGIN_STATUS_MISSING_SVN ; pinfo.status = PLUGIN_STATUS_MISSING_SVN ;
pinfo.info_string = "" ; pinfo.info_string = "" ;
dlclose(handle);
return false ; return false ;
} }
@ -340,6 +347,7 @@ bool RsPluginManager::loadPlugin(const std::string& plugin_name)
std::cerr << dlerror() << std::endl ; std::cerr << dlerror() << std::endl ;
pinfo.status = PLUGIN_STATUS_MISSING_SYMBOL ; pinfo.status = PLUGIN_STATUS_MISSING_SYMBOL ;
pinfo.info_string = _plugin_entry_symbol ; pinfo.info_string = _plugin_entry_symbol ;
dlclose(handle);
return false ; return false ;
} }
std::cerr << " -> Added function entry for symbol " << _plugin_entry_symbol << std::endl ; std::cerr << " -> Added function entry for symbol " << _plugin_entry_symbol << std::endl ;
@ -351,11 +359,13 @@ bool RsPluginManager::loadPlugin(const std::string& plugin_name)
std::cerr << " Plugin entry function " << _plugin_entry_symbol << " returns NULL ! It should return an object of type RsPlugin* " << std::endl; std::cerr << " Plugin entry function " << _plugin_entry_symbol << " returns NULL ! It should return an object of type RsPlugin* " << std::endl;
pinfo.status = PLUGIN_STATUS_NULL_PLUGIN ; pinfo.status = PLUGIN_STATUS_NULL_PLUGIN ;
pinfo.info_string = "Plugin entry " + _plugin_entry_symbol + "() return NULL" ; pinfo.info_string = "Plugin entry " + _plugin_entry_symbol + "() return NULL" ;
dlclose(handle);
return false ; return false ;
} }
pinfo.status = PLUGIN_STATUS_LOADED ; pinfo.status = PLUGIN_STATUS_LOADED ;
pinfo.plugin = p ; pinfo.plugin = p ;
pinfo.handle = handle;
p->setPlugInHandler(this); // WIN fix, cannot share global space with shared libraries p->setPlugInHandler(this); // WIN fix, cannot share global space with shared libraries
pinfo.info_string = "" ; pinfo.info_string = "" ;

View File

@ -12,7 +12,14 @@ class p3LinkMgr ;
class PluginInfo class PluginInfo
{ {
public:
PluginInfo() : handle(NULL), plugin(NULL), API_version(0), svn_revision(0), status(0) {}
public: public:
// Handle of the loaded plugin.
//
void *handle;
// Main object provided by the plugin. NULL is the plugin could not be loaded. // Main object provided by the plugin. NULL is the plugin could not be loaded.
// //
RsPlugin *plugin ; RsPlugin *plugin ;