Hi,
I noticed if I put multiple plugin factories in the same .so, SEMS
handles them fine, every one of them is loaded and accounted for, but
their onLoad() function is not called, only for the last one (in the
order of the loading, as written in the source code). The attached patch
fixes this issue.
br
Szo
Index: AmPlugIn.h
===================================================================
--- AmPlugIn.h (revision 18656)
+++ AmPlugIn.h (working copy)
@@ -115,7 +115,7 @@
virtual ~AmPlugIn();
/** @return -1 if failed, else 0. */
- int loadPlugIn(const string& file, const string& plugin_name, AmPluginFactory*& plugin);
+ int loadPlugIn(const string& file, const string& plugin_name, vector<AmPluginFactory*>& plugins);
int loadAudioPlugIn(amci_exports_t* exports);
int loadAppPlugIn(AmPluginFactory* cb);
Index: AmPlugIn.cpp
===================================================================
--- AmPlugIn.cpp (revision 18656)
+++ AmPlugIn.cpp (working copy)
@@ -209,12 +209,10 @@
DBG("loading %s ...\n",plugin_file.c_str());
AmPluginFactory* plugin = NULL;
- if( (err = loadPlugIn(plugin_file, plugin_name, plugin)) < 0 ) {
+ if( (err = loadPlugIn(plugin_file, plugin_name, loaded_plugins)) < 0 ) {
ERROR("while loading plug-in '%s'\n",plugin_file.c_str());
return -1;
}
- if (NULL != plugin)
- loaded_plugins.push_back(plugin);
}
closedir(dir);
@@ -239,13 +237,11 @@
plugin_file = directory + "/" + plugin_file;
DBG("loading %s...\n",plugin_file.c_str());
AmPluginFactory* plugin = NULL;
- if( (err = loadPlugIn(plugin_file, plugin_file, plugin)) < 0 ) {
+ if( (err = loadPlugIn(plugin_file, plugin_file, loaded_plugins)) < 0 ) {
ERROR("while loading plug-in '%s'\n",plugin_file.c_str());
// be strict here: if plugin not loaded, stop!
return err;
}
- if (NULL != plugin)
- loaded_plugins.push_back(plugin);
}
}
@@ -275,10 +271,9 @@
}
int AmPlugIn::loadPlugIn(const string& file, const string& plugin_name,
- AmPluginFactory*& plugin)
+ vector<AmPluginFactory*>& plugins)
{
-
- plugin = NULL; // default: not loaded
+ AmPluginFactory* plugin = NULL; // default: not loaded
int dlopen_flags = RTLD_NOW;
char* pname = strdup(plugin_name.c_str());
@@ -327,24 +322,28 @@
if(loadAppPlugIn(plugin))
goto error;
has_sym=true;
+ if (NULL != plugin) plugins.push_back(plugin);
}
if((fc = (FactoryCreate)dlsym(h_dl,FACTORY_SESSION_EVENT_HANDLER_EXPORT_STR)) != NULL){
plugin = (AmPluginFactory*)fc();
if(loadSehPlugIn(plugin))
goto error;
has_sym=true;
+ if (NULL != plugin) plugins.push_back(plugin);
}
if((fc = (FactoryCreate)dlsym(h_dl,FACTORY_PLUGIN_EXPORT_STR)) != NULL){
plugin = (AmPluginFactory*)fc();
if(loadBasePlugIn(plugin))
goto error;
has_sym=true;
+ if (NULL != plugin) plugins.push_back(plugin);
}
if((fc = (FactoryCreate)dlsym(h_dl,FACTORY_PLUGIN_CLASS_EXPORT_STR)) != NULL){
plugin = (AmPluginFactory*)fc();
if(loadDiPlugIn(plugin))
goto error;
has_sym=true;
+ if (NULL != plugin) plugins.push_back(plugin);
}
if((fc = (FactoryCreate)dlsym(h_dl,FACTORY_LOG_FACILITY_EXPORT_STR)) != NULL){
@@ -352,6 +351,7 @@
if(loadLogFacPlugIn(plugin))
goto error;
has_sym=true;
+ if (NULL != plugin) plugins.push_back(plugin);
}
if(!has_sym){
@@ -365,7 +365,6 @@
error:
dlclose(h_dl);
- plugin = NULL;
return -1;
}
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev