Author: anthm Date: Wed Jul 9 17:19:18 2008 New Revision: 8967 Modified: freeswitch/trunk/src/switch_ivr_async.c Log: a day at the races Modified: freeswitch/trunk/src/switch_ivr_async.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_async.c (original) +++ freeswitch/trunk/src/switch_ivr_async.c Wed Jul 9 17:19:18 2008 @@ -1490,6 +1490,7 @@ switch_mutex_t *mutex; switch_thread_cond_t *cond; switch_memory_pool_t *pool; + int ready; }; static void *SWITCH_THREAD_FUNC speech_thread(switch_thread_t *thread, void *obj) @@ -1505,6 +1506,8 @@ switch_core_session_read_lock(sth->session); switch_mutex_lock(sth->mutex); + sth->ready = 1; + while (switch_channel_ready(channel) && !switch_test_flag(sth->ah, SWITCH_ASR_FLAG_CLOSED)) { char *xmlstr = NULL; @@ -1619,9 +1622,11 @@ break; case SWITCH_ABC_TYPE_CLOSE:{ switch_core_asr_close(sth->ah, &flags); - switch_mutex_lock(sth->mutex); - switch_thread_cond_signal(sth->cond); - switch_mutex_unlock(sth->mutex); + if (sth->mutex && sth->cond && sth->ready) { + switch_mutex_lock(sth->mutex); + switch_thread_cond_signal(sth->cond); + switch_mutex_unlock(sth->mutex); + } } break; case SWITCH_ABC_TYPE_READ: