]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
count runlevel to prevent dup calls to the core init routines
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 4 Jan 2010 19:03:43 +0000 (19:03 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 4 Jan 2010 19:03:43 +0000 (19:03 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16140 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/private/switch_core_pvt.h
src/switch_core.c

index 6408920724c36c4f5bc267cdb8f5cfadf0eeb636..5b13cdea62fbb996327ce30c1d4b026d38fda994 100644 (file)
@@ -214,6 +214,7 @@ struct switch_runtime {
        char *odbc_user;
        char *odbc_pass;
        uint32_t debug_level;
+       uint32_t runlevel;
 };
 
 extern struct switch_runtime runtime;
index 184b6e1cb348ab041f2179539bf851854c3c58a8..0632a64b33c4e773228a86b6ee422ce2177c90fd 100644 (file)
@@ -52,7 +52,7 @@
 SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 };
 
 /* The main runtime obj we keep this hidden for ourselves */
-struct switch_runtime runtime;
+struct switch_runtime runtime = { 0 };
 static void switch_load_core_config(const char *file);
 
 static void send_heartbeat(void)
@@ -1174,8 +1174,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
        struct in_addr in;
        char hostname[256] = "";
 
-       memset(&runtime, 0, sizeof(runtime));
-       
+       if (runtime.runlevel > 0) {
+               /* one per customer */
+               return SWITCH_STATUS_SUCCESS;
+       }
+
+       runtime.runlevel++;
+
        runtime.dummy_cng_frame.data = runtime.dummy_data;
        runtime.dummy_cng_frame.datalen = sizeof(runtime.dummy_data);
        runtime.dummy_cng_frame.buflen = sizeof(runtime.dummy_data);
@@ -1467,6 +1472,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t
                return SWITCH_STATUS_GENERR;
        }
 
+       if (runtime.runlevel > 1) {
+               /* one per customer */
+               return SWITCH_STATUS_SUCCESS;
+       }
+
+       runtime.runlevel++;
+
        /* set signal handlers */
        signal(SIGINT, SIG_IGN);
 #ifdef SIGPIPE