]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
don't export our private functions. fix crash protection build.
authorMichael Jerris <mike@jerris.com>
Fri, 30 Mar 2007 02:20:13 +0000 (02:20 +0000)
committerMichael Jerris <mike@jerris.com>
Fri, 30 Mar 2007 02:20:13 +0000 (02:20 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4803 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/private/switch_core.h
src/switch_core.c
src/switch_core_memory.c
src/switch_core_session.c
src/switch_core_sqldb.c
src/switch_core_state_machine.c

index 90a4a344aa200dc8d0144a4f0022b83eb1f57a2d..11ea9cb025d7ac33aa925917e44ac3fd30601804 100644 (file)
@@ -143,7 +143,8 @@ struct switch_media_bug {
        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);
index 5ee66c3c50c8b97e7f6dab94bc2d2c47acc9dacf..7d5eeddc191d04458d55b58bfe473824fcf8ccbb 100644 (file)
@@ -43,9 +43,6 @@ static struct {
        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_DECLARE(switch_status_t) switch_core_init(char *console, const char **err
 
        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_DECLARE(switch_status_t) switch_core_init(char *console, const char **err
        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 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
                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);
index a773a15044b0b73205d0a15c1e6fc4b206bd54cc..32b2ef849b7948909d1cbdbdb0e7dc21288350d2 100644 (file)
@@ -212,7 +212,7 @@ SWITCH_DECLARE(void *) switch_core_alloc(switch_memory_pool_t *pool, switch_size
        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));
 
index 88a8aeb765db4b173b6224716930bc15738bcf04..5e5962592efc633d2ac48f86c5437418ded1364a 100644 (file)
@@ -638,56 +638,6 @@ SWITCH_DECLARE(unsigned int) switch_core_session_running(switch_core_session_t *
        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(uint32_t) switch_core_session_limit(uint32_t new_limit)
 }
 
 
-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;
index e3b154e83919327a44ee8a2d2b3e5f480a3ee0d2..1313048a2a397e3bcba751466658fd99b0a44177 100644 (file)
@@ -340,7 +340,7 @@ static void core_event_handler(switch_event_t *event)
 }
 
 
-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_start(switch_memory_pool_t *pool)
 
 }
 
-SWITCH_DECLARE(void) switch_core_sqldb_stop(void)
+void switch_core_sqldb_stop(void)
 {
        switch_queue_push(runtime.sql_queue, NULL);
 
index 3d9452fb3626fee68f5e534e9ddcf8a623aefa0a..363899a451232b0b84237ab19229d6d37039efca 100644 (file)
@@ -213,6 +213,66 @@ static void switch_core_standard_on_hibernate(switch_core_session_t *session)
        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_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
                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_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
        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;