Kamailio patch to stop crashes with TCP traffic
On some systems running Enswitch 3.14 or higher we've noticed Kamailio can crash if there is TCP traffic. The following patch was provided by Daniel-Constantin Mierla to fix it. Apparently the fix went into the 5.1 and 5.2 branches in October 2019.
Replace the exiting functions unload_perl() and perl_reload() from modules/app_perl/app_perl_mod.c or src/modules/app_perl/app_perl_mod.c file with the next content:
/* * */ int unload_perl(PerlInterpreter *p) { /* clean and reset everything */ PL_perl_destruct_level = 1; perl_destruct(p); perl_free(p); return 0; } /* * reload function. * Reinitializes the interpreter. Works, but execution for _all_ * children is difficult. */ int perl_reload(void) { if(my_perl) { unload_perl(my_perl); } my_perl = parser_init(); #ifdef 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; #endif if(my_perl) { LM_DBG("new perl interpreter initialized\n"); return 0; } else { LM_CRIT("failed to initialize a new perl interpreter - exiting\n"); exit(-1); } }