[asterisk-commits] file: trunk r184628 - /trunk/bridges/bridge_softmix.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 27 08:57:32 CDT 2009


Author: file
Date: Fri Mar 27 08:57:29 2009
New Revision: 184628

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=184628
Log:
Fix a potential race condition when creating a software based mixing bridge.

It was possible for no timer to become available between creating the bridge
and starting it. We now open a timer when creating it and keep it open until the
bridge is destroyed.

Modified:
    trunk/bridges/bridge_softmix.c

Modified: trunk/bridges/bridge_softmix.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/bridges/bridge_softmix.c?view=diff&rev=184628&r1=184627&r2=184628
==============================================================================
--- trunk/bridges/bridge_softmix.c (original)
+++ trunk/bridges/bridge_softmix.c Fri Mar 27 08:57:29 2009
@@ -91,7 +91,7 @@
 		return -1;
 	}
 
-	ast_timer_close(timingfd);
+	bridge->bridge_pvt = (void*)(unsigned long)timingfd;
 
 	return 0;
 }
@@ -199,11 +199,7 @@
 /*! \brief Function which acts as the mixing thread */
 static int softmix_bridge_thread(struct ast_bridge *bridge)
 {
-	int timingfd;
-
-	if ((timingfd = ast_timer_open()) < 0) {
-		return -1;
-	}
+	int timingfd = (unsigned short)(unsigned long)bridge->bridge_pvt;
 
 	ast_timer_set_rate(timingfd, (1000 / SOFTMIX_INTERVAL));
 
@@ -267,7 +263,6 @@
 		ao2_lock(bridge);
 	}
 
-	ast_timer_set_rate(timingfd, 0);
 	ast_timer_close(timingfd);
 
 	return 0;




More information about the asterisk-commits mailing list