Browse code

core: renamed global is_main to _ksr_is_main

- safer to avoid conflicts with other libs

(cherry picked from commit f3454dd9f2d065e7757e9d9680b815481d08269c)

Daniel-Constantin Mierla authored on 10/01/2022 17:31:38
Showing 3 changed files
... ...
@@ -159,7 +159,7 @@ extern char *avp_db_url;  /* db url used by user preferences (AVPs) */
159 159
 
160 160
 extern int reply_to_via;
161 161
 
162
-extern int is_main;
162
+extern int _ksr_is_main;
163 163
 extern int fixup_complete;
164 164
 
165 165
 /* debugging level for dumping memory status */
... ...
@@ -262,7 +262,7 @@ int fork_process(int child_id, char *desc, int make_sock)
262 262
 	#ifdef USE_TCP
263 263
 		sockfd[0]=sockfd[1]=-1;
264 264
 		if(make_sock && !tcp_disable){
265
-			if (!is_main){
265
+			if (!_ksr_is_main){
266 266
 				LM_CRIT("called from a non "
267 267
 						"\"main\" process! If forking from a module's "
268 268
 						"child_init() fork only if rank==PROC_MAIN or"
... ...
@@ -297,7 +297,7 @@ int fork_process(int child_id, char *desc, int make_sock)
297 297
 		goto error;
298 298
 	}else if (pid==0){
299 299
 		/* child */
300
-		is_main=0; /* a forked process cannot be the "main" one */
300
+		_ksr_is_main=0; /* a forked process cannot be the "main" one */
301 301
 		process_no=child_process_no;
302 302
 		daemon_status_on_fork_cleanup();
303 303
 		/* close tcp unix sockets if this is not tcp main */
... ...
@@ -401,8 +401,8 @@ int fork_tcp_process(int child_id, char *desc, int r, int *reader_fd_1)
401 401
 	reader_fd[0]=reader_fd[1]=-1;
402 402
 	ret=-1;
403 403
 
404
-	if (!is_main){
405
-		LM_CRIT("called from a non \"main\" process\n");
404
+	if (!_ksr_is_main){
405
+		LM_CRIT("called from a non \"main\" process (%d)\n", _ksr_is_main);
406 406
 		goto error;
407 407
 	}
408 408
 	if (tcp_main_pid){
... ...
@@ -441,7 +441,7 @@ int fork_tcp_process(int child_id, char *desc, int r, int *reader_fd_1)
441 441
 		goto end;
442 442
 	}
443 443
 	if (pid==0){
444
-		is_main=0; /* a forked process cannot be the "main" one */
444
+		_ksr_is_main=0; /* a forked process cannot be the "main" one */
445 445
 		process_no=child_process_no;
446 446
 		/* close unneeded unix sockets */
447 447
 		close_extra_socks(child_id, process_no);
... ...
@@ -522,7 +522,7 @@ extern FILE* yyin;
522 522
 extern int yyparse(void);
523 523
 
524 524
 
525
-int is_main=1; /* flag = is this the  "main" process? */
525
+int _ksr_is_main=1; /* flag = is this the  "main" process? */
526 526
 int fixup_complete=0; /* flag = is the fixup complete ? */
527 527
 
528 528
 char* pid_file = 0; /* filename as asked by use */
... ...
@@ -663,7 +663,7 @@ static void kill_all_children(int signum)
663 663
 		  * (only main can add processes, so from main is safe not to lock
664 664
 		  *  and moreover it avoids the lock-holding suicidal children problem)
665 665
 		  */
666
-		if (!is_main) lock_get(process_lock);
666
+		if (!_ksr_is_main) lock_get(process_lock);
667 667
 		for (r=1; r<*process_count; r++){
668 668
 			if (r==process_no) continue; /* try not to be suicidal */
669 669
 			if (pt[r].pid) {
... ...
@@ -672,7 +672,7 @@ static void kill_all_children(int signum)
672 672
 			else LM_CRIT("killing: %s > %d no pid!!!\n",
673 673
 							pt[r].desc, pt[r].pid);
674 674
 		}
675
-		if (!is_main) lock_release(process_lock);
675
+		if (!_ksr_is_main) lock_release(process_lock);
676 676
 	}
677 677
 }
678 678
 
... ...
@@ -846,7 +846,7 @@ void sig_usr(int signo)
846 846
 #endif
847 847
 #endif
848 848
 
849
-	if (is_main){
849
+	if (_ksr_is_main){
850 850
 		if (sig_flag==0) sig_flag=signo;
851 851
 		else /*  previous sig. not processed yet, ignoring? */
852 852
 			return; ;
... ...
@@ -3054,7 +3054,7 @@ try_again:
3054 3054
 	if (ret < 0)
3055 3055
 		goto error;
3056 3056
 	/*kill everything*/
3057
-	if (is_main) shutdown_children(SIGTERM, 0);
3057
+	if (_ksr_is_main) shutdown_children(SIGTERM, 0);
3058 3058
 	if (!dont_daemonize) {
3059 3059
 		if (daemon_status_send(0) < 0)
3060 3060
 			fprintf(stderr, "error sending exit status: %s [%d]\n",
... ...
@@ -3065,7 +3065,7 @@ try_again:
3065 3065
 
3066 3066
 error:
3067 3067
 	/*kill everything*/
3068
-	if (is_main) shutdown_children(SIGTERM, 0);
3068
+	if (_ksr_is_main) shutdown_children(SIGTERM, 0);
3069 3069
 	if (!dont_daemonize) {
3070 3070
 		if (daemon_status_send((char)-1) < 0)
3071 3071
 			fprintf(stderr, "error sending exit status: %s [%d]\n",