From 074afad5b5ea725abd421c1e545154136962c604 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 4 Jan 2010 19:03:43 +0000 Subject: [PATCH] count runlevel to prevent dup calls to the core init routines git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16140 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/private/switch_core_pvt.h | 1 + src/switch_core.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index 6408920724..5b13cdea62 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -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; diff --git a/src/switch_core.c b/src/switch_core.c index 184b6e1cb3..0632a64b33 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -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