Revision
16140
Author
anthm
Date
2010-01-04 13:03:43 -0600 (Mon, 04 Jan 2010)

Log Message

count runlevel to prevent dup calls to the core init routines

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h (16139 => 16140)


--- freeswitch/trunk/src/include/private/switch_core_pvt.h	2010-01-04 18:52:13 UTC (rev 16139)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h	2010-01-04 19:03:43 UTC (rev 16140)
@@ -214,6 +214,7 @@
 	char *odbc_user;
 	char *odbc_pass;
 	uint32_t debug_level;
+	uint32_t runlevel;
 };
 
 extern struct switch_runtime runtime;

Modified: freeswitch/trunk/src/switch_core.c (16139 => 16140)


--- freeswitch/trunk/src/switch_core.c	2010-01-04 18:52:13 UTC (rev 16139)
+++ freeswitch/trunk/src/switch_core.c	2010-01-04 19:03:43 UTC (rev 16140)
@@ -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 @@
 	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 @@
 		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