Skip to content

Commit

Permalink
app_perl: new param perl_destroy_func to specify perl destroy function
Browse files Browse the repository at this point in the history
- if set, the module will execute the specified perl function before
  re-initializing the interpreter at runtime
  • Loading branch information
miconda committed May 26, 2014
1 parent 794af34 commit 6fba7ed
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/app_perl/app_perl_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ char *filename = NULL;
* installed */
char *modpath = NULL;

/* Function to be called before perl interpreter instance is destroyed
* when attempting reinit */
static char *perl_destroy_func = NULL;

/* Allow unsafe module functions - functions with fixups. This will create
* memory leaks, the variable thus is not documented! */
int unsafemodfnc = 0;
Expand Down Expand Up @@ -128,6 +132,7 @@ static param_export_t params[] = {
{"modpath", STR_PARAM, &modpath},
{"unsafemodfnc", INT_PARAM, &unsafemodfnc},
{"reset_cycles", INT_PARAM, &_ap_reset_cycles_init},
{"perl_destroy_func", STR_PARAM, &perl_destroy_func},
{ 0, 0, 0 }
};

Expand Down Expand Up @@ -426,6 +431,7 @@ int app_perl_reset_interpreter(void)
{
struct timeval t1;
struct timeval t2;
char *args[] = { NULL };

if(*_ap_reset_cycles==0)
return 0;
Expand All @@ -437,6 +443,9 @@ int app_perl_reset_interpreter(void)
if(_ap_exec_cycles<=*_ap_reset_cycles)
return 0;

if(perl_destroy_func)
call_argv(perl_destroy_func, G_DISCARD | G_NOARGS, args);

gettimeofday(&t1, NULL);
if (perl_reload()<0) {
LM_ERR("perl interpreter cannot be reset [%d/%d]\n",
Expand Down

0 comments on commit 6fba7ed

Please sign in to comment.