[svn-commits] russell: branch 1.6.1 r140055 - in /branches/1.6.1: ./ channels/chan_iax2.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Aug 26 10:31:14 CDT 2008


Author: russell
Date: Tue Aug 26 10:31:13 2008
New Revision: 140055

URL: http://svn.digium.com/view/asterisk?view=rev&rev=140055
Log:
Merged revisions 140053 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r140053 | russell | 2008-08-26 10:29:25 -0500 (Tue, 26 Aug 2008) | 23 lines

Merged revisions 140051 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r140051 | russell | 2008-08-26 10:27:23 -0500 (Tue, 26 Aug 2008) | 15 lines

Fix a race condition with the IAX scheduler thread.  A lock and condition are
used here to allow newly scheduled tasks to wake up the scheduler just in case
the new task needs to run sooner than the current wakeup time when the thread
is sleeping.  However, there was a race condition such that a newly scheduled
task would not properly wake up the scheduler or affect the wake up period.
The order of execution would have been:

  1) Scheduler thread determines wake up time of N ms.
  2) Another thread schedules a task and signals the condition, with an
     execution time of < N ms.
  3) Scheduler thread locks and goes to sleep for N ms.

By moving the sleep time determination to inside the critical section, this
possibility is avoided.

........

................

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/channels/chan_iax2.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/channels/chan_iax2.c?view=diff&rev=140055&r1=140054&r2=140055
==============================================================================
--- branches/1.6.1/channels/chan_iax2.c (original)
+++ branches/1.6.1/channels/chan_iax2.c Tue Aug 26 10:31:13 2008
@@ -10155,15 +10155,14 @@
 	struct timespec ts;
 
 	for (;;) {
+		pthread_testcancel();
+		ast_mutex_lock(&sched_lock);
 		res = ast_sched_wait(sched);
 		if ((res > 1000) || (res < 0))
 			res = 1000;
 		wait = ast_tvadd(ast_tvnow(), ast_samp2tv(res, 1000));
 		ts.tv_sec = wait.tv_sec;
 		ts.tv_nsec = wait.tv_usec * 1000;
-
-		pthread_testcancel();
-		ast_mutex_lock(&sched_lock);
 		ast_cond_timedwait(&sched_cond, &sched_lock, &ts);
 		ast_mutex_unlock(&sched_lock);
 		pthread_testcancel();




More information about the svn-commits mailing list