Module: kamailio Branch: 5.1 Commit: 8cb302f39941b121875dd402ead726de6ec5a624 URL: https://github.com/kamailio/kamailio/commit/8cb302f39941b121875dd402ead726de...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2019-10-09T08:55:28+02:00
app_perl: first destroy old interpreter before creating the new one
- on interpreter reset, the new one may inherit globals from the old one, if that is not yet destroyed
(cherry picked from commit 58047ba61d0cbceebc8c85590970a573fc396aa5) (cherry picked from commit 8c70c16d10ed46f4ba8cf002a5b1599a02b5cb93)
---
Modified: src/modules/app_perl/app_perl_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/8cb302f39941b121875dd402ead726de... Patch: https://github.com/kamailio/kamailio/commit/8cb302f39941b121875dd402ead726de...
---
diff --git a/src/modules/app_perl/app_perl_mod.c b/src/modules/app_perl/app_perl_mod.c index 74f08acff2..7a10a506c8 100644 --- a/src/modules/app_perl/app_perl_mod.c +++ b/src/modules/app_perl/app_perl_mod.c @@ -264,6 +264,8 @@ PerlInterpreter *parser_init(void) { * */ int unload_perl(PerlInterpreter *p) { + /* clean and reset everything */ + PL_perl_destruct_level = 1; perl_destruct(p); perl_free(p);
@@ -278,26 +280,26 @@ int unload_perl(PerlInterpreter *p) { */ int perl_reload(void) { - - PerlInterpreter *new_perl; - - new_perl = parser_init(); - - if (new_perl) { + if(my_perl) { unload_perl(my_perl); - my_perl = new_perl; + } + my_perl = parser_init(); + #ifdef PERL_EXIT_DESTRUCT_END - PL_exit_flags |= PERL_EXIT_DESTRUCT_END; + PL_exit_flags |= PERL_EXIT_DESTRUCT_END; #else #warning Perl 5.8.x should be used. Please upgrade. #warning This binary will be unsupported. - PL_exit_flags |= PERL_EXIT_EXPECTED; + PL_exit_flags |= PERL_EXIT_EXPECTED; #endif + + if(my_perl) { + LM_DBG("new perl interpreter initialized\n"); return 0; } else { - return -1; + LM_CRIT("failed to initialize a new perl interpreter - exiting\n"); + exit(-1); } - }