[asterisk-commits] russell: branch russell/ast_channel_ao2 r174208 - /team/russell/ast_channel_a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Feb 7 10:41:54 CST 2009


Author: russell
Date: Sat Feb  7 10:41:53 2009
New Revision: 174208

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=174208
Log:
finish converting res_snmp

Modified:
    team/russell/ast_channel_ao2/res/snmp/agent.c

Modified: team/russell/ast_channel_ao2/res/snmp/agent.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/res/snmp/agent.c?view=diff&rev=174208&r1=174207&r2=174208
==============================================================================
--- team/russell/ast_channel_ao2/res/snmp/agent.c (original)
+++ team/russell/ast_channel_ao2/res/snmp/agent.c Sat Feb  7 10:41:53 2009
@@ -583,13 +583,28 @@
 		long_ret = tech->transfer ? 1 : 2;
 		return (u_char *)&long_ret;
 	case ASTCHANTYPECHANNELS:
+	{
+		struct ast_channel_iterator *iter;
+
 		long_ret = 0;
-		for (chan = ast_channel_walk_locked(NULL); chan; chan = ast_channel_walk_locked(chan)) {
-			if (chan->tech == tech)
+
+		if (!(iter = ast_channel_iterator_all_new(0))) {
+			return NULL;
+		}
+
+		while ((chan = ast_channel_iterator_next(iter))) {
+			ast_channel_lock(chan);
+			if (chan->tech == tech) {
 				long_ret++;
+			}
 			ast_channel_unlock(chan);
-		}
-		return (u_char *)&long_ret;
+			chan = ast_channel_unref(chan);
+		}
+
+		ast_channel_iterator_destroy(iter);
+
+		return (u_char *)&long_ret;
+	}
 	default:
 		break;
 	}
@@ -601,15 +616,25 @@
 {
 	static unsigned long long_ret;
 	struct ast_channel *chan = NULL;
+	struct ast_channel_iterator *iter;
 
 	long_ret = 0;
-	if (header_generic(vp, name, length, exact, var_len, write_method))
-		return NULL;
-
-	while ((chan = ast_channel_walk_locked(chan))) {
-		if (ast_bridged_channel(chan))
+
+	if (header_generic(vp, name, length, exact, var_len, write_method)) {
+		return NULL;
+	}
+
+	if (!(iter = ast_channel_iterator_all_new(0))) {
+		return NULL;
+	}
+
+	while ((chan = ast_channel_iterator_next(iter))) {
+		ast_channel_lock(chan);
+		if (ast_bridged_channel(chan)) {
 			long_ret++;
+		}
 		ast_channel_unlock(chan);
+		chan = ast_channel_unref(chan);
 	}
 
 	*var_len = sizeof(long_ret);




More information about the asterisk-commits mailing list