[sr-dev] git:master: app_perl: new param perl_destroy_func to specify perl destroy function

Daniel-Constantin Mierla miconda at gmail.com
Mon May 26 15:55:50 CEST 2014


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Mon May 26 15:47:07 2014 +0200

app_perl: new param perl_destroy_func to specify perl destroy function

- if set, the module will execute the specified perl function before
  re-initializing the interpreter at runtime

---

 modules/app_perl/app_perl_mod.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/modules/app_perl/app_perl_mod.c b/modules/app_perl/app_perl_mod.c
index 625fec3..035e04d 100644
--- a/modules/app_perl/app_perl_mod.c
+++ b/modules/app_perl/app_perl_mod.c
@@ -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;
@@ -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 }
 };
 
@@ -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;
@@ -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",




More information about the sr-dev mailing list