[asterisk-commits] mmichelson: branch russell/ast_channel_ao2 r183552 - in /team/russell/ast_cha...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 20 10:21:02 CDT 2009


Author: mmichelson
Date: Fri Mar 20 10:20:58 2009
New Revision: 183552

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=183552
Log:
Make each channel contain a list of autochans instead of having one global list.

This addresses Vadim's idea on review board. Since ABI compatibility is already being
broken with the ast_channel_ao2 branch, we can afford to add the autochan list to the
channel structure directly.

I couldn't test this since app_dahdiscan is not compiling. I'll get that fixed and commit
that, too.


Modified:
    team/russell/ast_channel_ao2/include/asterisk/channel.h
    team/russell/ast_channel_ao2/main/autochan.c
    team/russell/ast_channel_ao2/main/channel.c

Modified: team/russell/ast_channel_ao2/include/asterisk/channel.h
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/include/asterisk/channel.h?view=diff&rev=183552&r1=183551&r2=183552
==============================================================================
--- team/russell/ast_channel_ao2/include/asterisk/channel.h (original)
+++ team/russell/ast_channel_ao2/include/asterisk/channel.h Fri Mar 20 10:20:58 2009
@@ -501,6 +501,7 @@
 	struct ast_jb jb;				/*!< The jitterbuffer state */
 	struct timeval dtmf_tv;				/*!< The time that an in process digit began, or the last digit ended */
 	AST_LIST_HEAD_NOLOCK(datastores, ast_datastore) datastores; /*!< Data stores on the channel */
+	AST_LIST_HEAD_NOLOCK(autochans, ast_autochan) autochans; /*!< Autochans on the channel */
 
 	unsigned long insmpl;				/*!< Track the read/written samples for monitor use */
 	unsigned long outsmpl;				/*!< Track the read/written samples for monitor use */

Modified: team/russell/ast_channel_ao2/main/autochan.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/main/autochan.c?view=diff&rev=183552&r1=183551&r2=183552
==============================================================================
--- team/russell/ast_channel_ao2/main/autochan.c (original)
+++ team/russell/ast_channel_ao2/main/autochan.c Fri Mar 20 10:20:58 2009
@@ -31,8 +31,6 @@
 #include "asterisk/options.h"
 #include "asterisk/channel.h"
 
-AST_LIST_HEAD_STATIC(autochans, ast_autochan);
-
 struct ast_autochan *ast_autochan_setup(struct ast_channel *chan)
 {
 	struct ast_autochan *autochan;
@@ -43,9 +41,9 @@
 
 	autochan->chan = ast_channel_ref(chan);
 
-	AST_LIST_LOCK(&autochans);
-	AST_LIST_INSERT_TAIL(&autochans, autochan, list);
-	AST_LIST_UNLOCK(&autochans);
+	ast_channel_lock(autochan->chan);
+	AST_LIST_INSERT_TAIL(&autochan->chan->autochans, autochan, list);
+	ast_channel_unlock(autochan->chan);
 
 	ast_debug(1, "Created autochan %p to hold channel %s (%p)\n", autochan, chan->name, chan);
 
@@ -56,8 +54,8 @@
 {
 	struct ast_autochan *autochan_iter;
 
-	AST_LIST_LOCK(&autochans);
-	AST_LIST_TRAVERSE_SAFE_BEGIN(&autochans, autochan_iter, list) {
+	ast_channel_lock(autochan->chan);
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&autochan->chan->autochans, autochan_iter, list) {
 		if (autochan_iter == autochan) {
 			AST_LIST_REMOVE_CURRENT(list);
 			ast_debug(1, "Removed autochan %p from the list, about to free it\n", autochan);
@@ -65,7 +63,7 @@
 		}
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
-	AST_LIST_UNLOCK(&autochans);
+	ast_channel_unlock(autochan->chan);
 	autochan->chan = ast_channel_unref(autochan->chan);
 	ast_free(autochan);
 }
@@ -74,8 +72,7 @@
 {
 	struct ast_autochan *autochan;
 
-	AST_LIST_LOCK(&autochans);
-	AST_LIST_TRAVERSE(&autochans, autochan, list) {
+	AST_LIST_TRAVERSE(&old_chan->autochans, autochan, list) {
 		if (autochan->chan == old_chan) {
 			autochan->chan = ast_channel_unref(old_chan);
 			autochan->chan = ast_channel_ref(new_chan);
@@ -85,5 +82,4 @@
 			}
 		}
 	}
-	AST_LIST_UNLOCK(&autochans);
 }

Modified: team/russell/ast_channel_ao2/main/channel.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/main/channel.c?view=diff&rev=183552&r1=183551&r2=183552
==============================================================================
--- team/russell/ast_channel_ao2/main/channel.c (original)
+++ team/russell/ast_channel_ao2/main/channel.c Fri Mar 20 10:20:58 2009
@@ -927,6 +927,8 @@
 	AST_LIST_HEAD_INIT_NOLOCK(headp);
 	
 	AST_LIST_HEAD_INIT_NOLOCK(&tmp->datastores);
+
+	AST_LIST_HEAD_INIT_NOLOCK(&tmp->autochans);
 	
 	ast_string_field_set(tmp, language, defaultlanguage);
 




More information about the asterisk-commits mailing list