[Freeswitch-svn] [commit] r4803 - in freeswitch/trunk/src: . include/private

Freeswitch SVN mikej at freeswitch.org
Thu Mar 29 22:20:14 EDT 2007


Author: mikej
Date: Thu Mar 29 22:20:13 2007
New Revision: 4803

Modified:
   freeswitch/trunk/src/include/private/switch_core.h
   freeswitch/trunk/src/switch_core.c
   freeswitch/trunk/src/switch_core_memory.c
   freeswitch/trunk/src/switch_core_session.c
   freeswitch/trunk/src/switch_core_sqldb.c
   freeswitch/trunk/src/switch_core_state_machine.c

Log:
don't export our private functions.  fix crash protection build.

Modified: freeswitch/trunk/src/include/private/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core.h	(original)
+++ freeswitch/trunk/src/include/private/switch_core.h	Thu Mar 29 22:20:13 2007
@@ -143,7 +143,8 @@
 	struct switch_media_bug *next;
 };
 
-SWITCH_DECLARE(void) switch_core_sqldb_start(switch_memory_pool_t *pool);
-SWITCH_DECLARE(void) switch_core_sqldb_stop(void);
-SWITCH_DECLARE(void) switch_core_session_init(switch_memory_pool_t *pool);
-SWITCH_DECLARE(switch_memory_pool_t *) switch_core_memory_init(void);
+void switch_core_sqldb_start(switch_memory_pool_t *pool);
+void switch_core_sqldb_stop(void);
+void switch_core_session_init(switch_memory_pool_t *pool);
+void switch_core_state_machine_init(switch_memory_pool_t *pool);
+switch_memory_pool_t *switch_core_memory_init(void);

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Thu Mar 29 22:20:13 2007
@@ -43,9 +43,6 @@
 	switch_time_t initiated;
 	switch_hash_t *global_vars;
 	switch_memory_pool_t *memory_pool;
-#ifdef CRASH_PROT
-	switch_hash_t *stack_table;
-#endif
 	const switch_state_handler_table_t *state_handlers[SWITCH_MAX_STATE_HANDLERS];
 	int state_handler_index;
 	FILE *console;
@@ -426,8 +423,11 @@
 
 	switch_core_set_globals();
 	switch_core_session_init(runtime.memory_pool);
+	switch_core_state_machine_init(runtime.memory_pool);
 	switch_core_hash_init(&runtime.global_vars, runtime.memory_pool);
 
+
+
 	if (switch_xml_init(runtime.memory_pool, err) != SWITCH_STATUS_SUCCESS) {
 		apr_terminate();
 		return SWITCH_STATUS_MEMERR;
@@ -486,12 +486,6 @@
 	switch_rtp_init(runtime.memory_pool);
 	runtime.running = 1;
 
-
-#ifdef CRASH_PROT
-	switch_core_hash_init(&runtime.stack_table, runtime.memory_pool);
-#endif
-
-
 	switch_scheduler_task_thread_start();
 	runtime.initiated = switch_time_now();
 
@@ -673,8 +667,6 @@
 		runtime.console = NULL;
 	}
 
-	switch_yield(1000000);
-
 	switch_safe_free(SWITCH_GLOBAL_dirs.base_dir);
 	switch_safe_free(SWITCH_GLOBAL_dirs.mod_dir);
 	switch_safe_free(SWITCH_GLOBAL_dirs.conf_dir);

Modified: freeswitch/trunk/src/switch_core_memory.c
==============================================================================
--- freeswitch/trunk/src/switch_core_memory.c	(original)
+++ freeswitch/trunk/src/switch_core_memory.c	Thu Mar 29 22:20:13 2007
@@ -212,7 +212,7 @@
 	return ptr;
 }
 
-SWITCH_DECLARE(switch_memory_pool_t *) switch_core_memory_init(void)
+switch_memory_pool_t *switch_core_memory_init(void)
 {
 	memset(&runtime, 0, sizeof(runtime));
 

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Thu Mar 29 22:20:13 2007
@@ -638,56 +638,6 @@
 	return session->thread_running;
 }
 
-#ifdef CRASH_PROT
-#if defined (__GNUC__) && defined (LINUX)
-#include <execinfo.h>
-#include <stdio.h>
-#include <stdlib.h>
-#define STACK_LEN 10
-
-/* Obtain a backtrace and print it to stdout. */
-static void print_trace(void)
-{
-	void *array[STACK_LEN];
-	size_t size;
-	char **strings;
-	size_t i;
-
-	size = backtrace(array, STACK_LEN);
-	strings = backtrace_symbols(array, size);
-
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Obtained %zd stack frames.\n", size);
-
-	for (i = 0; i < size; i++) {
-		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CRIT, "%s\n", strings[i]);
-	}
-
-	free(strings);
-}
-#else
-static void print_trace(void)
-{
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Trace not avaliable =(\n");
-}
-#endif
-
-
-static void handle_fatality(int sig)
-{
-	switch_thread_id_t thread_id;
-	jmp_buf *env;
-
-	if (sig && (thread_id = switch_thread_self())
-		&& (env = (jmp_buf *) apr_hash_get(runtime.stack_table, &thread_id, sizeof(thread_id)))) {
-		print_trace();
-		longjmp(*env, sig);
-	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Caught signal %d for unmapped thread!", sig);
-		abort();
-	}
-}
-#endif
-
 
 SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session_t **session)
 {
@@ -900,7 +850,7 @@
 }
 
 
-SWITCH_DECLARE(void) switch_core_session_init(switch_memory_pool_t *pool)
+void switch_core_session_init(switch_memory_pool_t *pool)
 {
 	memset(&runtime, 0, sizeof(runtime));
 	runtime.session_limit = 1000;

Modified: freeswitch/trunk/src/switch_core_sqldb.c
==============================================================================
--- freeswitch/trunk/src/switch_core_sqldb.c	(original)
+++ freeswitch/trunk/src/switch_core_sqldb.c	Thu Mar 29 22:20:13 2007
@@ -340,7 +340,7 @@
 }
 
 
-SWITCH_DECLARE(void) switch_core_sqldb_start(switch_memory_pool_t *pool)
+void switch_core_sqldb_start(switch_memory_pool_t *pool)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr;;
@@ -405,7 +405,7 @@
 
 }
 
-SWITCH_DECLARE(void) switch_core_sqldb_stop(void)
+void switch_core_sqldb_stop(void)
 {
 	switch_queue_push(runtime.sql_queue, NULL);
 

Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c	(original)
+++ freeswitch/trunk/src/switch_core_state_machine.c	Thu Mar 29 22:20:13 2007
@@ -213,6 +213,66 @@
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard HIBERNATE\n");
 }
 
+
+#ifdef CRASH_PROT
+static switch_hash_t *stack_table;
+#if defined (__GNUC__) && defined (LINUX)
+#include <execinfo.h>
+#include <stdio.h>
+#include <stdlib.h>
+#define STACK_LEN 10
+
+/* Obtain a backtrace and print it to stdout. */
+static void print_trace(void)
+{
+	void *array[STACK_LEN];
+	size_t size;
+	char **strings;
+	size_t i;
+
+	size = backtrace(array, STACK_LEN);
+	strings = backtrace_symbols(array, size);
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Obtained %zd stack frames.\n", size);
+
+	for (i = 0; i < size; i++) {
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CRIT, "%s\n", strings[i]);
+	}
+
+	free(strings);
+}
+#else
+static void print_trace(void)
+{
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Trace not avaliable =(\n");
+}
+#endif
+
+
+static void handle_fatality(int sig)
+{
+	switch_thread_id_t thread_id;
+	jmp_buf *env;
+
+	if (sig && (thread_id = switch_thread_self())
+		&& (env = (jmp_buf *) apr_hash_get(stack_table, &thread_id, sizeof(thread_id)))) {
+		print_trace();
+		longjmp(*env, sig);
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Caught signal %d for unmapped thread!", sig);
+		abort();
+	}
+}
+#endif
+
+void switch_core_state_machine_init(switch_memory_pool_t *pool)
+{
+	(void)0;
+#ifdef CRASH_PROT
+	switch_core_hash_init(&stack_table, pool);
+#endif
+}
+
 SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
 {
 	switch_channel_state_t state = CS_NEW, laststate = CS_HANGUP, midstate = CS_DONE, endstate;
@@ -241,7 +301,7 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Thread has crashed for channel %s\n", switch_channel_get_name(session->channel));
 		switch_channel_hangup(session->channel, SWITCH_CAUSE_CRASH);
 	} else {
-		apr_hash_set(runtime.stack_table, &thread_id, sizeof(thread_id), &env);
+		apr_hash_set(stack_table, &thread_id, sizeof(thread_id), &env);
 	}
 #endif
 	/*
@@ -596,7 +656,7 @@
 	switch_mutex_unlock(session->mutex);
 
 #ifdef CRASH_PROT
-	apr_hash_set(runtime.stack_table, &thread_id, sizeof(thread_id), NULL);
+	apr_hash_set(stack_table, &thread_id, sizeof(thread_id), NULL);
 #endif
 	session->thread_running = 0;
 



More information about the Freeswitch-svn mailing list