From f3454dd9f2d065e7757e9d9680b815481d08269c Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Mon, 10 Jan 2022 18:31:38 +0100 Subject: [PATCH] core: renamed global is_main to _ksr_is_main - safer to avoid conflicts with other libs --- src/core/globals.h | 2 +- src/core/pt.c | 10 +++++----- src/main.c | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/core/globals.h b/src/core/globals.h index f3777d37a83..3a104391426 100644 --- a/src/core/globals.h +++ b/src/core/globals.h @@ -159,7 +159,7 @@ extern char *avp_db_url; /* db url used by user preferences (AVPs) */ extern int reply_to_via; -extern int is_main; +extern int _ksr_is_main; extern int fixup_complete; /* debugging level for dumping memory status */ diff --git a/src/core/pt.c b/src/core/pt.c index a3094a29fbe..e3dc94d5a34 100644 --- a/src/core/pt.c +++ b/src/core/pt.c @@ -262,7 +262,7 @@ int fork_process(int child_id, char *desc, int make_sock) #ifdef USE_TCP sockfd[0]=sockfd[1]=-1; if(make_sock && !tcp_disable){ - if (!is_main){ + if (!_ksr_is_main){ LM_CRIT("called from a non " "\"main\" process! If forking from a module's " "child_init() fork only if rank==PROC_MAIN or" @@ -297,7 +297,7 @@ int fork_process(int child_id, char *desc, int make_sock) goto error; }else if (pid==0){ /* child */ - is_main=0; /* a forked process cannot be the "main" one */ + _ksr_is_main=0; /* a forked process cannot be the "main" one */ process_no=child_process_no; daemon_status_on_fork_cleanup(); /* 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) reader_fd[0]=reader_fd[1]=-1; ret=-1; - if (!is_main){ - LM_CRIT("called from a non \"main\" process\n"); + if (!_ksr_is_main){ + LM_CRIT("called from a non \"main\" process (%d)\n", _ksr_is_main); goto error; } if (tcp_main_pid){ @@ -441,7 +441,7 @@ int fork_tcp_process(int child_id, char *desc, int r, int *reader_fd_1) goto end; } if (pid==0){ - is_main=0; /* a forked process cannot be the "main" one */ + _ksr_is_main=0; /* a forked process cannot be the "main" one */ process_no=child_process_no; /* close unneeded unix sockets */ close_extra_socks(child_id, process_no); diff --git a/src/main.c b/src/main.c index 60435e865ee..016a90cabe7 100644 --- a/src/main.c +++ b/src/main.c @@ -508,7 +508,7 @@ extern FILE* yyin; extern int yyparse(void); -int is_main=1; /* flag = is this the "main" process? */ +int _ksr_is_main=1; /* flag = is this the "main" process? */ int fixup_complete=0; /* flag = is the fixup complete ? */ char* pid_file = 0; /* filename as asked by use */ @@ -649,7 +649,7 @@ static void kill_all_children(int signum) * (only main can add processes, so from main is safe not to lock * and moreover it avoids the lock-holding suicidal children problem) */ - if (!is_main) lock_get(process_lock); + if (!_ksr_is_main) lock_get(process_lock); for (r=1; r<*process_count; r++){ if (r==process_no) continue; /* try not to be suicidal */ if (pt[r].pid) { @@ -658,7 +658,7 @@ static void kill_all_children(int signum) else LM_CRIT("killing: %s > %d no pid!!!\n", pt[r].desc, pt[r].pid); } - if (!is_main) lock_release(process_lock); + if (!_ksr_is_main) lock_release(process_lock); } } @@ -832,7 +832,7 @@ void sig_usr(int signo) #endif #endif - if (is_main){ + if (_ksr_is_main){ if (sig_flag==0) sig_flag=signo; else /* previous sig. not processed yet, ignoring? */ return; ; @@ -3070,7 +3070,7 @@ int main(int argc, char** argv) if (ret < 0) goto error; /*kill everything*/ - if (is_main) shutdown_children(SIGTERM, 0); + if (_ksr_is_main) shutdown_children(SIGTERM, 0); if (!dont_daemonize) { if (daemon_status_send(0) < 0) fprintf(stderr, "error sending exit status: %s [%d]\n", @@ -3081,7 +3081,7 @@ int main(int argc, char** argv) error: /*kill everything*/ - if (is_main) shutdown_children(SIGTERM, 0); + if (_ksr_is_main) shutdown_children(SIGTERM, 0); if (!dont_daemonize) { if (daemon_status_send((char)-1) < 0) fprintf(stderr, "error sending exit status: %s [%d]\n",