Skip to content

Commit

Permalink
secsipid: clod dlopen handle on mod destroy
Browse files Browse the repository at this point in the history
(cherry picked from commit 4752ad4)
  • Loading branch information
miconda committed May 18, 2021
1 parent d2fd064 commit 59e7e30
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/modules/secsipid/secsipid_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

MODULE_VERSION

static void *_secsipid_dlhandle = NULL;

static int secsipid_expire = 300;
static int secsipid_timeout = 5;

Expand Down Expand Up @@ -107,6 +109,10 @@ struct module_exports exports = {
*/
static int mod_init(void)
{
if(_secsipid_dlhandle!=0) {
dlclose(_secsipid_dlhandle);
_secsipid_dlhandle = NULL;
}
return 0;
}

Expand All @@ -115,7 +121,6 @@ static int mod_init(void)
*/
static int child_init(int rank)
{
void *handle = NULL;
char *errstr = NULL;
char *modpath = NULL;
secsipid_proc_bind_f bind_f = NULL;
Expand All @@ -135,16 +140,16 @@ static int child_init(int rank)
/* for openbsd */
#define RTLD_NOW DL_LAZY
#endif
handle = dlopen(modpath, RTLD_NOW); /* resolve all symbols now */
if (handle==0) {
_secsipid_dlhandle = dlopen(modpath, RTLD_NOW); /* resolve all symbols now */
if (_secsipid_dlhandle==0) {
LM_ERR("could not open module <%s>: %s\n", modpath, dlerror());
goto error;
}
/* launch register */
bind_f = (secsipid_proc_bind_f)dlsym(handle, "secsipid_proc_bind");
bind_f = (secsipid_proc_bind_f)dlsym(_secsipid_dlhandle, "secsipid_proc_bind");
if (((errstr=(char*)dlerror())==NULL) && bind_f!=NULL) {
/* version control */
if (!ksr_version_control(handle, modpath)) {
if (!ksr_version_control(_secsipid_dlhandle, modpath)) {
goto error;
}
/* no error - call it */
Expand Down

0 comments on commit 59e7e30

Please sign in to comment.