aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-02 19:25:14 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-02 19:25:14 +0000
commitdd31f6ce403c39aad5b4974bde5fdbf010aa6194 (patch)
tree9ff96a1a26594f4f50a3718200a9a01365cb0666 /channels
parentb4db36099ebb03ff7908e4af044e66f3433cca98 (diff)
Fix the case where a dynamic thread times out waiting for something to do
during the first time it runs. This shouldn't ever happen, but we should account for it anyway. (pointed out by pete, who works with mihai) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@77949 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_iax2.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index d21cf8827..5cc34ee77 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -7874,14 +7874,23 @@ static void *iax2_process_thread(void *data)
ts.tv_sec = tv.tv_sec;
ts.tv_nsec = tv.tv_usec * 1000;
if (ast_cond_timedwait(&thread->cond, &thread->lock, &ts) == ETIMEDOUT) {
+ /* This thread was never put back into the available dynamic
+ * thread list, so just go away. */
+ if (!put_into_idle) {
+ ast_mutex_unlock(&thread->lock);
+ break;
+ }
AST_LIST_LOCK(&dynamic_list);
/* Account for the case where this thread is acquired *right* after a timeout */
if ((t = AST_LIST_REMOVE(&dynamic_list, thread, list)))
iaxdynamicthreadcount--;
AST_LIST_UNLOCK(&dynamic_list);
if (t) {
+ /* This dynamic thread timed out waiting for a task and was
+ * not acquired immediately after the timeout,
+ * so it's time to go away. */
ast_mutex_unlock(&thread->lock);
- break; /* exiting the main loop */
+ break;
}
/* Someone grabbed our thread *right* after we timed out.
* Wait for them to set us up with something to do and signal