Module: kamailio
Branch: master
Commit: 6c7d38ee0fcbd482ff0527178481345fc93a7fc8
URL: 
https://github.com/kamailio/kamailio/commit/6c7d38ee0fcbd482ff0527178481345fc93a7fc8

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2015-09-21T09:01:08+02:00

core: name of structure exported by a module can be prefixed with module name

- some modules use the flag for global exporting, which can lead to
  naming conflicts
- related to GH#333

---

Modified: sr_module.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/6c7d38ee0fcbd482ff0527178481345fc93a7fc8.diff
Patch: 
https://github.com/kamailio/kamailio/commit/6c7d38ee0fcbd482ff0527178481345fc93a7fc8.patch

---

diff --git a/sr_module.c b/sr_module.c
index 216c953..057bf02 100644
--- a/sr_module.c
+++ b/sr_module.c
@@ -459,6 +459,8 @@ int load_module(char* mod_path)
        int new_dlflags;
        int retries;
        int path_type;
+       str expref;
+       char exbuf[64];
 
 #ifndef RTLD_NOW
 /* for openbsd */
@@ -611,9 +613,24 @@ int load_module(char* mod_path)
                }
        }
        exp = (union module_exports_u*)dlsym(handle, DLSYM_PREFIX "exports");
-       if ( (error =(char*)dlerror())!=0 ){
-               LM_ERR("%s\n", error);
-               goto error1;
+       if(exp==NULL) {
+               /* 'exports' structure not found, look up for 
'_modulename_exports' */
+               mdir = strrchr(mod_path, '/');
+               if (!mdir) {
+                       expref.s = mod_path;
+               } else {
+                       expref.s = mdir+1;
+               }
+               expref.len = strlen(expref.s);
+               if(expref.len>3 && strcmp(expref.s+expref.len-3, ".so")==0)
+                       expref.len -= 3;
+               snprintf(exbuf, 62, DLSYM_PREFIX "_%.*s_exports", expref.len, 
expref.s);
+               exp = (union module_exports_u*)dlsym(handle, exbuf);
+               LM_DBG("looking up exports with name: %s\n", exbuf);
+               if ( (error =(char*)dlerror())!=0 ){
+                       LM_ERR("%s\n", error);
+                       goto error1;
+               }
        }
        /* hack to allow for kamailio style dlflags inside exports */
        if (*mod_if_ver == 1) {


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to