Browse code

core: more use of ksr_exit() macro to follow --atexit param

Daniel-Constantin Mierla authored on 09/02/2021 09:50:03
Showing 4 changed files
... ...
@@ -39,6 +39,7 @@
39 39
 	#include "select.h"
40 40
 	#include "cfg.tab.h"
41 41
 	#include "sr_compat.h"
42
+	#include "daemonize.h"
42 43
 	#include "ppcfg.h"
43 44
 
44 45
 	/* states */
... ...
@@ -1308,7 +1309,7 @@ IMPORTFILE      "import_file"
1308 1309
 									LM_CRIT(
1309 1310
 										"error at %s line %d: '-' not allowed\n",
1310 1311
 										(finame)?finame:"cfg", line);
1311
-									exit(-1);
1312
+									ksr_exit(-1);
1312 1313
 								}
1313 1314
 <DEFINE_ID>{ID}                 {	count();
1314 1315
 									ksr_cfg_print_part(yytext);
... ...
@@ -1350,7 +1351,7 @@ IMPORTFILE      "import_file"
1350 1351
 									LM_CRIT(
1351 1352
 										"error at %s line %d: '-' not allowed\n",
1352 1353
 										(finame)?finame:"cfg", line);
1353
-									exit(-1);
1354
+									ksr_exit(-1);
1354 1355
 								}
1355 1356
 <IFDEF_ID>{ID}                { count();
1356 1357
 								pp_ifdef_var(yyleng, yytext);
... ...
@@ -1404,7 +1405,7 @@ IMPORTFILE      "import_file"
1404 1405
 				if(sr_push_yy_state(s_buf.s, 0)<0)
1405 1406
 				{
1406 1407
 					LOG(L_CRIT, "error at %s line %d\n", (finame)?finame:"cfg", line);
1407
-					exit(-1);
1408
+					ksr_exit(-1);
1408 1409
 				}
1409 1410
 				memset(&s_buf, 0, sizeof(s_buf));
1410 1411
 				ksr_cfg_print_initial_state();
... ...
@@ -1418,7 +1419,7 @@ IMPORTFILE      "import_file"
1418 1419
 				if(sr_push_yy_state(s_buf.s, 1)<0)
1419 1420
 				{
1420 1421
 					LM_CRIT("error at %s line %d\n", (finame)?finame:"cfg", line);
1421
-					exit(-1);
1422
+					ksr_exit(-1);
1422 1423
 				}
1423 1424
 				memset(&s_buf, 0, sizeof(s_buf));
1424 1425
 				ksr_cfg_print_initial_state();
... ...
@@ -1439,7 +1440,7 @@ IMPORTFILE      "import_file"
1439 1440
 				ksr_cfg_print_part(yytext);
1440 1441
 				if(pp_define_env(yytext, yyleng) < 0) {
1441 1442
 					LM_CRIT("error at %s line %d\n", (finame)?finame:"cfg", line);
1442
-					exit(-1);
1443
+					ksr_exit(-1);
1443 1444
 				}
1444 1445
 				state = INITIAL;
1445 1446
 				ksr_cfg_print_initial_state();
... ...
@@ -1610,7 +1611,7 @@ static char* addstr(struct str_buf* dst_b, char* src, int len)
1610 1611
 	return dst_b->s;
1611 1612
 error:
1612 1613
 	PKG_MEM_CRITICAL;
1613
-	exit(-1);
1614
+	ksr_exit(-1);
1614 1615
 }
1615 1616
 
1616 1617
 
... ...
@@ -69,6 +69,7 @@
69 69
 #include "ppcfg.h"
70 70
 #include "pvapi.h"
71 71
 #include "config.h"
72
+#include "daemonize.h"
72 73
 #include "cfg_core.h"
73 74
 #include "cfg/cfg.h"
74 75
 #ifdef CORE_TLS
... ...
@@ -3521,7 +3522,7 @@ cmd:
3521 3522
 		if (mod_func_action != NULL) {
3522 3523
 			LM_ERR("function used inside params of another function: %s\n", $1);
3523 3524
 			yyerror("use of function execution inside params not allowed\n");
3524
-			exit(-1);
3525
+			ksr_exit(-1);
3525 3526
 		}
3526 3527
 		mod_func_action = mk_action(MODULE0_T, 2, MODEXP_ST, NULL, NUMBER_ST, 0);
3527 3528
 		} LPAREN func_params RPAREN	{
... ...
@@ -45,6 +45,7 @@
45 45
 #include "fmsg.h"
46 46
 #include "async_task.h"
47 47
 #include "shm_init.h"
48
+#include "daemonize.h"
48 49
 
49 50
 #include <sys/stat.h>
50 51
 #include <regex.h>
... ...
@@ -541,7 +542,7 @@ reload:
541 542
 	}
542 543
 	/* version control */
543 544
 	if (!version_control(handle, path)) {
544
-		exit(-1);
545
+		ksr_exit(-1);
545 546
 	}
546 547
 	/* launch register */
547 548
 	mr = (mod_register_function)dlsym(handle, "mod_register");
... ...
@@ -52,6 +52,7 @@
52 52
 #include "ut.h"
53 53
 #include "trim.h"
54 54
 #include "pt.h"
55
+#include "daemonize.h"
55 56
 #include "cfg/cfg_struct.h"
56 57
 #ifdef CORE_TLS
57 58
 #include "tls/tls_server.h"
... ...
@@ -2009,7 +2010,7 @@ void tcp_receive_loop(int unix_sock)
2009 2010
 error:
2010 2011
 	destroy_io_wait(&io_w);
2011 2012
 	LM_CRIT("exiting...");
2012
-	exit(-1);
2013
+	ksr_exit(-1);
2013 2014
 }
2014 2015
 
2015 2016