Module: kamailio
Branch: 5.2
Commit: 8c70c16d10ed46f4ba8cf002a5b1599a02b5cb93
URL:
https://github.com/kamailio/kamailio/commit/8c70c16d10ed46f4ba8cf002a5b1599…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-10-07T10:43:18+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)
---
Modified: src/modules/app_perl/app_perl_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/8c70c16d10ed46f4ba8cf002a5b1599…
Patch:
https://github.com/kamailio/kamailio/commit/8c70c16d10ed46f4ba8cf002a5b1599…
---
diff --git a/src/modules/app_perl/app_perl_mod.c b/src/modules/app_perl/app_perl_mod.c
index 785d4c39b0..3112f9acce 100644
--- a/src/modules/app_perl/app_perl_mod.c
+++ b/src/modules/app_perl/app_perl_mod.c
@@ -262,6 +262,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);
@@ -276,26 +278,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);
}
-
}