Browse code

app_perl: added modparam to control behaviour on perl_parse() code

Daniel-Constantin Mierla authored on 07/07/2022 07:04:37
Showing 1 changed files
... ...
@@ -71,6 +71,7 @@ int unsafemodfnc = 0;
71 71
 int _ap_reset_cycles_init = 0;
72 72
 int _ap_exec_cycles = 0;
73 73
 int *_ap_reset_cycles = 0;
74
+int _ap_parse_mode = 0;
74 75
 
75 76
 /* Reference to the running Perl interpreter instance */
76 77
 PerlInterpreter *my_perl = NULL;
... ...
@@ -123,6 +124,7 @@ static param_export_t params[] = {
123 124
 	{"unsafemodfnc", INT_PARAM, &unsafemodfnc},
124 125
 	{"reset_cycles", INT_PARAM, &_ap_reset_cycles_init},
125 126
 	{"perl_destroy_func",  PARAM_STRING, &perl_destroy_func},
127
+	{"parse_mode", PARAM_INT, &_ap_parse_mode},
126 128
 	{ 0, 0, 0 }
127 129
 };
128 130
 
... ...
@@ -237,8 +239,21 @@ PerlInterpreter *parser_init(void) {
237 239
 	pr=perl_parse(new_perl, xs_init, argc, argv, NULL);
238 240
 
239 241
 	if (pr) {
240
-		LM_WARN("parsed perl file \"%s\" returned with code %d - continue\n",
242
+		if(_ap_parse_mode==0) {
243
+			LM_WARN("parsed perl file \"%s\" returned with code %d - continue\n",
241 244
 				argv[argc-1], pr);
245
+		} else {
246
+			LM_ERR("failed parsing perl file \"%s\" with code %d.\n",
247
+					argv[argc-1], pr);
248
+			if (modpathset_start) {
249
+				for (i = modpathset_start; i <= modpathset_end; i++) {
250
+					pkg_free(argv[i]);
251
+				}
252
+			}
253
+			perl_destruct(new_perl);
254
+			perl_free(new_perl);
255
+			return NULL;
256
+		}
242 257
 	} else {
243 258
 		LM_INFO("successfully parsed perl file \"%s\"\n", argv[argc-1]);
244 259
 	}