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
This commit is contained in:
Anthony Minessale 2010-01-04 19:03:43 +00:00
parent 3cb315d6d4
commit 074afad5b5
2 changed files with 16 additions and 3 deletions

View File

@ -214,6 +214,7 @@ struct switch_runtime {
char *odbc_user; char *odbc_user;
char *odbc_pass; char *odbc_pass;
uint32_t debug_level; uint32_t debug_level;
uint32_t runlevel;
}; };
extern struct switch_runtime runtime; extern struct switch_runtime runtime;

View File

@ -52,7 +52,7 @@
SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 }; SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 };
/* The main runtime obj we keep this hidden for ourselves */ /* 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 switch_load_core_config(const char *file);
static void send_heartbeat(void) 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; struct in_addr in;
char hostname[256] = ""; 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.data = runtime.dummy_data;
runtime.dummy_cng_frame.datalen = sizeof(runtime.dummy_data); runtime.dummy_cng_frame.datalen = sizeof(runtime.dummy_data);
runtime.dummy_cng_frame.buflen = 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; return SWITCH_STATUS_GENERR;
} }
if (runtime.runlevel > 1) {
/* one per customer */
return SWITCH_STATUS_SUCCESS;
}
runtime.runlevel++;
/* set signal handlers */ /* set signal handlers */
signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);
#ifdef SIGPIPE #ifdef SIGPIPE