diff -urN asterisk-1.4.9.orig/channels/chan_iax2.c asterisk-1.4.9/channels/chan_iax2.c --- asterisk-1.4.9.orig/channels/chan_iax2.c 2007-07-24 12:32:20.000000000 -0400 +++ asterisk-1.4.9/channels/chan_iax2.c 2007-08-01 15:43:47.000000000 -0400 @@ -715,6 +715,7 @@ time_t checktime; ast_mutex_t lock; ast_cond_t cond; + int ready_for_signal; /*! if this thread is processing a full frame, some information about that frame will be stored here, so we can avoid dispatching any more full @@ -900,6 +901,10 @@ } else { /* All went well and the thread is up, so increment our count */ iaxdynamicthreadcount++; + + /* Wait for the thread to be ready before returning it to the caller */ + while (!thread->ready_for_signal) + usleep(1); } } } @@ -7854,6 +7859,9 @@ /* Wait for something to signal us to be awake */ ast_mutex_lock(&thread->lock); + /* Flag that we're ready to accept signals */ + thread->ready_for_signal = 1; + /* Put into idle list if applicable */ if (put_into_idle) insert_idle_thread(thread);