]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 77949 via svnmerge from
authorRussell Bryant <russell@russellbryant.com>
Thu, 2 Aug 2007 19:26:12 +0000 (19:26 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 2 Aug 2007 19:26:12 +0000 (19:26 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r77949 | russell | 2007-08-02 14:25:14 -0500 (Thu, 02 Aug 2007) | 5 lines

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: https://origsvn.digium.com/svn/asterisk/trunk@77950 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c

index c035b151a5eb02aae2db8c3a5efac38f1a648f3e..72bf28f73ffb3326fd14c7f2e54d6459f9ad1834 100644 (file)
@@ -8392,14 +8392,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)))
                                        ast_atomic_fetchadd_int(&iaxdynamicthreadcount, -1);
                                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