slight fix on last commit

This commit is contained in:
Anthony Minessale 2010-09-17 14:49:43 -05:00
parent 0477cb67f5
commit 4e41e4c584
2 changed files with 17 additions and 7 deletions

View File

@ -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));
}

View File

@ -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;