Skip to content

Commit

Permalink
app_perl: first destroy old interpreter before creating the new one
Browse files Browse the repository at this point in the history
- on interpreter reset, the new one may inherit globals from the old
one, if that is not yet destroyed

(cherry picked from commit 58047ba)
  • Loading branch information
miconda committed Oct 7, 2019
1 parent 0e22d01 commit 8c70c16
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/modules/app_perl/app_perl_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}

}


Expand Down

0 comments on commit 8c70c16

Please sign in to comment.