[asterisk-commits] russell: trunk r77944 - in /trunk: ./ channels/chan_iax2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 2 13:05:23 CDT 2007


Author: russell
Date: Thu Aug  2 13:05:23 2007
New Revision: 77944

URL: http://svn.digium.com/view/asterisk?view=rev&rev=77944
Log:
Merged revisions 77943 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r77943 | russell | 2007-08-02 13:04:43 -0500 (Thu, 02 Aug 2007) | 9 lines

Fix another race condition in the handling of dynamic threads.  If the dynamic
thread timed out waiting for something to do, but was acquired to perform an
action immediately afterwords, then wait on the condition again to give the
other thread a chance to finish setting up the data for what action this thread
should perform.  Otherwise, if it immediately continues, it will perform the
wrong action.
(reported on IRC by mihai, patch by me)
(related to issue #10289)

........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_iax2.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=77944&r1=77943&r2=77944
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Thu Aug  2 13:05:23 2007
@@ -8392,14 +8392,20 @@
 			ts.tv_sec = tv.tv_sec;
 			ts.tv_nsec = tv.tv_usec * 1000;
 			if (ast_cond_timedwait(&thread->cond, &thread->lock, &ts) == ETIMEDOUT) {
-				ast_mutex_unlock(&thread->lock);
 				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)
+				if (t) {
+					ast_mutex_unlock(&thread->lock);
 					break;		/* exiting the main loop */
+				}
+				/* Someone grabbed our thread *right* after we timed out.
+				 * Wait for them to set us up with something to do and signal
+				 * us to continue. */
+				ast_cond_timedwait(&thread->cond, &thread->lock, &ts);
+				ast_mutex_unlock(&thread->lock);
 			}
 			if (!t)
 				ast_mutex_unlock(&thread->lock);




More information about the asterisk-commits mailing list