Module: kamailio
Branch: master
Commit: f3454dd9f2d065e7757e9d9680b815481d08269c
URL: 
https://github.com/kamailio/kamailio/commit/f3454dd9f2d065e7757e9d9680b815481d08269c

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2022-01-10T18:37:59+01:00

core: renamed global is_main to _ksr_is_main

- safer to avoid conflicts with other libs

---

Modified: src/core/globals.h
Modified: src/core/pt.c
Modified: src/main.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/f3454dd9f2d065e7757e9d9680b815481d08269c.diff
Patch: 
https://github.com/kamailio/kamailio/commit/f3454dd9f2d065e7757e9d9680b815481d08269c.patch

---

diff --git a/src/core/globals.h b/src/core/globals.h
index f3777d37a8..3a10439142 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 a3094a29fb..e3dc94d5a3 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 60435e865e..016a90cabe 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",


_______________________________________________
Kamailio (SER) - Development Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to