From 4e41e4c584a1208c96ca69b250e4df002952376a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 17 Sep 2010 14:49:43 -0500 Subject: [PATCH] slight fix on last commit --- src/mod/applications/mod_spandsp/mod_spandsp_fax.c | 13 +++++++++---- src/switch_core_sqldb.c | 11 ++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index 51e843778b..2ea3eb00a3 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -122,8 +122,13 @@ static struct { -static void wake_thread(void) +static void wake_thread(int force) { + if (force) { + switch_thread_cond_signal(globals.cond); + return; + } + if (switch_mutex_trylock(globals.cond_mutex) == SWITCH_STATUS_SUCCESS) { switch_thread_cond_signal(globals.cond); switch_mutex_unlock(globals.cond_mutex); @@ -140,7 +145,7 @@ static int add_pvt(pvt_t *pvt) t38_state_list.head = pvt; switch_mutex_unlock(t38_state_list.mutex); r = 1; - wake_thread(); + wake_thread(0); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error launching thread\n"); } @@ -175,7 +180,7 @@ static int del_pvt(pvt_t *del_pvt) switch_mutex_unlock(t38_state_list.mutex); - wake_thread(); + wake_thread(0); return r; } @@ -1345,7 +1350,7 @@ void mod_spandsp_fax_shutdown(void) switch_status_t tstatus = SWITCH_STATUS_SUCCESS; t38_state_list.thread_running = 0; - wake_thread(); + wake_thread(1); switch_thread_join(&tstatus, t38_state_list.thread); memset(&globals, 0, sizeof(globals)); } diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 4c742f342f..a5322751cd 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -464,8 +464,13 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t return status; } -static void wake_thread(void) +static void wake_thread(int force) { + if (force) { + switch_thread_cond_signal(sql_manager.cond); + return; + } + if (switch_mutex_trylock(sql_manager.cond_mutex) == SWITCH_STATUS_SUCCESS) { switch_thread_cond_signal(sql_manager.cond); switch_mutex_unlock(sql_manager.cond_mutex); @@ -1407,7 +1412,7 @@ static void core_event_handler(switch_event_t *event) switch_queue_push(sql_manager.sql_queue[0], sql[i]); } sql[i] = NULL; - wake_thread(); + wake_thread(0); } } } @@ -1681,7 +1686,7 @@ void switch_core_sqldb_stop(void) switch_queue_push(sql_manager.sql_queue[0], NULL); switch_queue_push(sql_manager.sql_queue[1], NULL); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Waiting for unfinished SQL transactions\n"); - wake_thread(); + wake_thread(1); } sql_manager.thread_running = -1;