From 61fe806c0a4c6f42510b01af71a1fe76d0ec62e4 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 2 Apr 2012 14:51:23 -0500 Subject: [PATCH 1/6] delete subs on 481 --- src/mod/endpoints/mod_sofia/sofia.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index bedafc2e5e..ebd083cae1 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -87,8 +87,8 @@ void sofia_handle_sip_r_notify(switch_core_session_t *session, int status, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, sofia_dispatch_event_t *de, tagi_t tags[]) { -#if 0 - if (status >= 300 && sip && !sip->sip_retry_after && sip->sip_call_id && (!sofia_private || !sofia_private->is_call)) { + + if (status == 481 && sip && !sip->sip_retry_after && sip->sip_call_id && (!sofia_private || !sofia_private->is_call)) { char *sql; sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", sip->sip_call_id->i_id); @@ -96,7 +96,7 @@ void sofia_handle_sip_r_notify(switch_core_session_t *session, int status, sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); nua_handle_destroy(nh); } -#endif + } #define url_set_chanvars(session, url, varprefix) _url_set_chanvars(session, url, #varprefix "_user", #varprefix "_host", #varprefix "_port", #varprefix "_uri", #varprefix "_params") From 972504a3ca3fc516466e6f039da167d67ba93047 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 2 Apr 2012 15:00:35 -0500 Subject: [PATCH 2/6] unset logger on global destroy --- libs/freetdm/src/ftdm_io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index fa62f5b425..caab35143a 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -5829,6 +5829,8 @@ FT_DECLARE(ftdm_status_t) ftdm_global_destroy(void) /* destroy signaling and io modules */ ftdm_unload_modules(); + ftdm_global_set_logger( NULL ); + /* finally destroy the globals */ ftdm_mutex_lock(globals.mutex); ftdm_sched_destroy(&globals.timingsched); From afdf50d42311a7d0615853cf170afb4bd9ab3bac Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 2 Apr 2012 15:33:45 -0500 Subject: [PATCH 3/6] stop sched thread quicker on global destroy --- libs/freetdm/src/ftdm_sched.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libs/freetdm/src/ftdm_sched.c b/libs/freetdm/src/ftdm_sched.c index c48c3e9433..e644067aad 100644 --- a/libs/freetdm/src/ftdm_sched.c +++ b/libs/freetdm/src/ftdm_sched.c @@ -119,10 +119,15 @@ static void *run_main_schedule(ftdm_thread_t *thread, void *data) /* there are no free runs, wait a bit and check again (FIXME: use ftdm_interrupt_t for this) */ ftdm_mutex_unlock(sched_globals.mutex); - ftdm_sleep(sleepms); + if (ftdm_running()) { + ftdm_sleep(sleepms); + } } for (current = sched_globals.freeruns; current; current = current->next) { + if (!ftdm_running()) { + break; + } /* first run the schedule */ ftdm_sched_run(current); @@ -142,7 +147,9 @@ static void *run_main_schedule(ftdm_thread_t *thread, void *data) ftdm_mutex_unlock(sched_globals.mutex); - ftdm_sleep(sleepms); + if (ftdm_running()) { + ftdm_sleep(sleepms); + } } ftdm_log(FTDM_LOG_NOTICE, "Main scheduling thread going out ...\n"); sched_globals.running = 0; From 139dc3e34e98f7fb3159b9232d1057234b7d986e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 2 Apr 2012 16:01:54 -0500 Subject: [PATCH 4/6] fix race condition where network lists are not created yet so nat detection does not work in sofia during startup --- src/switch_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/switch_core.c b/src/switch_core.c index 9b876d8458..4eeb02e447 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1875,6 +1875,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t runtime.runlevel++; switch_core_set_signal_handlers(); + switch_load_network_lists(SWITCH_FALSE); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bringing up environment.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Loading Modules.\n"); @@ -1884,7 +1885,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t return SWITCH_STATUS_GENERR; } - switch_load_network_lists(SWITCH_FALSE); + switch_load_core_config("post_load_switch.conf"); From 6138fc87532933e5f0ce5ec4e25be6f91b1c4d01 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 2 Apr 2012 16:03:37 -0500 Subject: [PATCH 5/6] FS-4038 can you try this --- src/switch_channel.c | 4 +++- src/switch_ivr_bridge.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/switch_channel.c b/src/switch_channel.c index c3970ea8e2..76161bc9c5 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1380,7 +1380,7 @@ SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, sw for (;;) { if ((channel->state < CS_HANGUP && channel->state == channel->running_state && channel->running_state == want_state) || - (other_channel && switch_channel_down_nosig(other_channel)) || switch_channel_down_nosig(channel)) { + (other_channel && switch_channel_down_nosig(other_channel)) || switch_channel_down(channel)) { break; } switch_yield(20000); @@ -1399,6 +1399,8 @@ SWITCH_DECLARE(void) switch_channel_wait_for_state_timeout(switch_channel_t *cha break; } + switch_channel_check_signal(channel, SWITCH_TRUE); + switch_cond_next(); if (++count >= timeout) { diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 06dc31e1cb..b75549c417 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -776,7 +776,7 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio state = switch_channel_get_state(other_channel); running_state = switch_channel_get_running_state(other_channel); - if (switch_channel_down_nosig(other_channel) || switch_channel_down_nosig(channel)) { + if (switch_channel_down_nosig(other_channel) || switch_channel_down(channel)) { break; } From 647740e9a479bb8453bdf85cfdd1b9a65cfb4ec5 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 2 Apr 2012 16:20:35 -0500 Subject: [PATCH 6/6] cleanup after yourself --- libs/freetdm/mod_freetdm/mod_freetdm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 1c41ed3b74..9b6641d7b0 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -4834,11 +4834,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load) ftdm_global_set_config_directory(SWITCH_GLOBAL_dirs.conf_dir); if (ftdm_global_init() != FTDM_SUCCESS) { + ftdm_global_destroy(); ftdm_log(FTDM_LOG_ERROR, "Error loading FreeTDM\n"); return SWITCH_STATUS_TERM; } if (ftdm_global_configuration() != FTDM_SUCCESS) { + ftdm_global_destroy(); ftdm_log(FTDM_LOG_ERROR, "Error configuring FreeTDM\n"); return SWITCH_STATUS_TERM; }