From ec27618fc8821af1446540d4963869a1f9be6572 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Mon, 11 Jun 2012 10:43:42 -0400 Subject: [PATCH] don't segfault after starting sofia, upon xml_open_config lookup failure for the profile from launch_sofia_worker_thread --- src/mod/endpoints/mod_sofia/sofia.c | 6 +++++- src/switch_apr.c | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 78036c1895..13e632af9f 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -2252,7 +2252,11 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void sofia_clear_pflag_locked(profile, PFLAG_SHUTDOWN); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Waiting for worker thread\n"); - switch_thread_join(&st, worker_thread); + if ( worker_thread ) { + switch_thread_join(&st, worker_thread); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: Sofia worker thead failed to start\n"); + } sanity = 4; while (profile->inuse) { diff --git a/src/switch_apr.c b/src/switch_apr.c index 426bed59f5..5936c7223e 100644 --- a/src/switch_apr.c +++ b/src/switch_apr.c @@ -1169,6 +1169,11 @@ SWITCH_DECLARE(switch_status_t) switch_thread_exit(switch_thread_t *thd, switch_ */ SWITCH_DECLARE(switch_status_t) switch_thread_join(switch_status_t *retval, switch_thread_t *thd) { + if ( !thd ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: Attempting to join thread that does not exist\n"); + return SWITCH_STATUS_FALSE; + } + return apr_thread_join((apr_status_t *) retval, (apr_thread_t *) thd); }