[asterisk-commits] russell: branch 1.4 r77949 - /branches/1.4/channels/chan_iax2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 2 14:25:15 CDT 2007


Author: russell
Date: Thu Aug  2 14:25:14 2007
New Revision: 77949

URL: http://svn.digium.com/view/asterisk?view=rev&rev=77949
Log:
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)

Modified:
    branches/1.4/channels/chan_iax2.c

Modified: branches/1.4/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_iax2.c?view=diff&rev=77949&r1=77948&r2=77949
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Thu Aug  2 14:25:14 2007
@@ -7874,14 +7874,23 @@
 			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




More information about the asterisk-commits mailing list