Module: kamailio
Branch: master
Commit: 2fe556a1e2c43d33106f121c05b857d4f1f7b380
URL:
https://github.com/kamailio/kamailio/commit/2fe556a1e2c43d33106f121c05b857d…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-04-25T15:36:48+02:00
core: kemi - handle the case when a module is reloaded with different flags
- avoid having same module exported twice
---
Modified: src/core/kemi.c
---
Diff:
https://github.com/kamailio/kamailio/commit/2fe556a1e2c43d33106f121c05b857d…
Patch:
https://github.com/kamailio/kamailio/commit/2fe556a1e2c43d33106f121c05b857d…
---
diff --git a/src/core/kemi.c b/src/core/kemi.c
index 28468de..145cb9a 100644
--- a/src/core/kemi.c
+++ b/src/core/kemi.c
@@ -791,10 +791,20 @@ int sr_kemi_modules_add(sr_kemi_t *klist)
_sr_kemi_modules[_sr_kemi_modules_size].kexp = _sr_kemi_hdr;
_sr_kemi_modules_size++;
}
- LM_DBG("adding module: %.*s\n", klist[0].mname.len, klist[0].mname.s);
- _sr_kemi_modules[_sr_kemi_modules_size].mname = klist[0].mname;
- _sr_kemi_modules[_sr_kemi_modules_size].kexp = klist;
- _sr_kemi_modules_size++;
+ if((_sr_kemi_modules_size>1)
+ && (_sr_kemi_modules[_sr_kemi_modules_size-1].mname.len
+ ==klist[0].mname.len)
+ && (strncmp(_sr_kemi_modules[_sr_kemi_modules_size-1].mname.s,
+ klist[0].mname.s, klist[0].mname.len)==0)) {
+ /* handle re-open of the module */
+ LM_DBG("updating module: %.*s\n", klist[0].mname.len, klist[0].mname.s);
+ _sr_kemi_modules[_sr_kemi_modules_size-1].kexp = klist;
+ } else {
+ LM_DBG("adding module: %.*s\n", klist[0].mname.len, klist[0].mname.s);
+ _sr_kemi_modules[_sr_kemi_modules_size].mname = klist[0].mname;
+ _sr_kemi_modules[_sr_kemi_modules_size].kexp = klist;
+ _sr_kemi_modules_size++;
+ }
return 0;
}