Module: sems
Branch: master
Commit: 48853bf6eab20b28a570f9e76b752fb186528081
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=48853bf6eab20b28a570f9e76b752fb186528081

Author: Szókovács Róbert <[email protected]>
Committer: Szókovács Róbert <[email protected]>
Date:   Mon Oct 21 15:07:03 2013 +0200

core: b/f: call all onLoad() functions
In case of multiple plugin factories in the same .so, only for the last one
(in the order of the loading, as written in the source code) was called.

---

 core/AmPlugIn.cpp |   21 +++++++++------------
 core/AmPlugIn.h   |    2 +-
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/core/AmPlugIn.cpp b/core/AmPlugIn.cpp
index a1861f4..ac909c7 100644
--- a/core/AmPlugIn.cpp
+++ b/core/AmPlugIn.cpp
@@ -202,13 +202,10 @@ int AmPlugIn::load(const string& directory, const string& 
plugins)
       string plugin_file = directory + "/" + plugin_name;
 
       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);
@@ -232,14 +229,11 @@ int AmPlugIn::load(const string& directory, const string& 
plugins)
 
       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);
     }
   }
 
@@ -269,10 +263,9 @@ void AmPlugIn::set_load_rtld_global(const string& 
plugin_name) {
 }
 
 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());
@@ -321,24 +314,28 @@ int AmPlugIn::loadPlugIn(const string& file, const 
string& plugin_name,
     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){
@@ -346,6 +343,7 @@ int AmPlugIn::loadPlugIn(const string& file, const string& 
plugin_name,
     if(loadLogFacPlugIn(plugin))
       goto error;
     has_sym=true;
+    if (NULL != plugin) plugins.push_back(plugin);
   }
 
   if(!has_sym){
@@ -359,7 +357,6 @@ int AmPlugIn::loadPlugIn(const string& file, const string& 
plugin_name,
 
  error:
   dlclose(h_dl);
-  plugin = NULL;
   return -1;
 }
 
diff --git a/core/AmPlugIn.h b/core/AmPlugIn.h
index 7bb42a1..3895ec3 100644
--- a/core/AmPlugIn.h
+++ b/core/AmPlugIn.h
@@ -115,7 +115,7 @@ class AmPlugIn : public AmPayloadProvider
   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);

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to