[asterisk-commits] dvossel: branch 1.6.2 r270868 - in /branches/1.6.2: ./ channels/chan_iax2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 16 12:37:42 CDT 2010


Author: dvossel
Date: Wed Jun 16 12:37:38 2010
New Revision: 270868

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

................
  r270867 | dvossel | 2010-06-16 12:36:51 -0500 (Wed, 16 Jun 2010) | 28 lines
  
  Merged revisions 270866 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r270866 | dvossel | 2010-06-16 12:35:29 -0500 (Wed, 16 Jun 2010) | 22 lines
    
    fixes chan_iax2 race condition
    
    There is code in chan_iax2.c that attempts to guarantee that only a single
    active thread will handle a call number at a time.  This code works once
    the thread is added to an active_list of threads, but we are not currently
    guaranteed that a newly activated thread will enter the active_list immediately
    because it is left up to the thread to add itself after frames have been
    queued to it.  This means that if two frames come in for the same call number
    at the same time, it is possible for them to grab two separate threads because
    the first thread did not add itself to the active_list fast enough.  This
    causes some pretty complex problems.
    
    This patch resolves this race condition by immediately adding an activated
    thread to the active_list within the network thread and only depending on
    the thread to remove itself once it is done processing the frames queued to
    it.  By doing this we are guaranteed that if another frame for the same call
    number comes in at the same time, that this thread will immediately be found
    in the active_list of threads.
    
    Review: https://reviewboard.asterisk.org/r/720/
  ........
................

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

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

Modified: branches/1.6.2/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/channels/chan_iax2.c?view=diff&rev=270868&r1=270867&r2=270868
==============================================================================
--- branches/1.6.2/channels/chan_iax2.c (original)
+++ branches/1.6.2/channels/chan_iax2.c Wed Jun 16 12:37:38 2010
@@ -9252,6 +9252,7 @@
 			memcpy(&thread->ffinfo.sin, &thread->iosin, sizeof(thread->ffinfo.sin));
 			thread->ffinfo.type = fh->type;
 			thread->ffinfo.csub = fh->csub;
+			AST_LIST_INSERT_HEAD(&active_list, thread, list);
 		}
 		AST_LIST_UNLOCK(&active_list);
 	}
@@ -11215,11 +11216,6 @@
 		if (thread->iostate == IAX_IOSTATE_IDLE)
 			continue;
 
-		/* Add ourselves to the active list now */
-		AST_LIST_LOCK(&active_list);
-		AST_LIST_INSERT_HEAD(&active_list, thread, list);
-		AST_LIST_UNLOCK(&active_list);
-
 		/* See what we need to do */
 		switch(thread->iostate) {
 		case IAX_IOSTATE_READY:
@@ -11243,7 +11239,9 @@
 		thread->curfunc[0]='\0';
 #endif		
 
-		/* Now... remove ourselves from the active list, and return to the idle list */
+		/* The network thread added us to the active_thread list when we were given
+		 * frames to process, Now that we are done, we must remove ourselves from
+		 * the active list, and return to the idle list */
 		AST_LIST_LOCK(&active_list);
 		AST_LIST_REMOVE(&active_list, thread, list);
 		AST_LIST_UNLOCK(&active_list);




More information about the asterisk-commits mailing list