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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 6 17:36:34 CST 2009


Author: russell
Date: Fri Feb  6 17:36:34 2009
New Revision: 174083

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=174083
Log:
convert res_agi and res_clioriginate

Modified:
    team/russell/ast_channel_ao2/res/res_agi.c
    team/russell/ast_channel_ao2/res/res_clioriginate.c

Modified: team/russell/ast_channel_ao2/res/res_agi.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/res/res_agi.c?view=diff&rev=174083&r1=174082&r2=174083
==============================================================================
--- team/russell/ast_channel_ao2/res/res_agi.c (original)
+++ team/russell/ast_channel_ao2/res/res_agi.c Fri Feb  6 17:36:34 2009
@@ -543,20 +543,27 @@
 		return NULL;
 	}
 
-	if (a->argc < 4)
+	if (a->argc < 4) {
 		return CLI_SHOWUSAGE;
-	chan = ast_get_channel_by_name_locked(a->argv[2]);
-	if (!chan) {
+	}
+
+	if (!(chan = ast_channel_get_by_name(a->argv[2]))) {
 		ast_log(LOG_WARNING, "Channel %s does not exists or cannot lock it\n", a->argv[2]);
 		return CLI_FAILURE;
 	}
+
 	if (add_agi_cmd(chan, a->argv[3], (a->argc > 4 ? a->argv[4] : ""))) {
 		ast_log(LOG_WARNING, "failed to add AGI command to queue of channel %s\n", chan->name);
 		ast_channel_unlock(chan);
+		chan = ast_channel_unref(chan);
 		return CLI_FAILURE;
 	}
+
 	ast_log(LOG_DEBUG, "Added AGI command to channel %s queue\n", chan->name);
+
 	ast_channel_unlock(chan);
+	chan = ast_channel_unref(chan);
+
 	return CLI_SUCCESS;
 }
 
@@ -578,24 +585,32 @@
 	const char *cmdid   = astman_get_header(m, "CommandID");
 	struct ast_channel *chan;
 	char buf[256];
+
 	if (ast_strlen_zero(channel) || ast_strlen_zero(cmdbuff)) {
 		astman_send_error(s, m, "Both, Channel and Command are *required*");
 		return 0;
 	}
-	chan = ast_get_channel_by_name_locked(channel);
-	if (!chan) {
+
+	if (!(chan = ast_channel_get_by_name(channel))) {
 		snprintf(buf, sizeof(buf), "Channel %s does not exists or cannot get its lock", channel);
 		astman_send_error(s, m, buf);
 		return 0;
 	}
+
+	ast_channel_lock(chan);
+
 	if (add_agi_cmd(chan, cmdbuff, cmdid)) {
 		snprintf(buf, sizeof(buf), "Failed to add AGI command to channel %s queue", chan->name);
 		astman_send_error(s, m, buf);
 		ast_channel_unlock(chan);
 		return 0;
 	}
+
 	astman_send_ack(s, m, "Added AGI command to queue");
+
 	ast_channel_unlock(chan);
+	chan = ast_channel_unref(chan);
+
 	return 0;
 }
 
@@ -1675,12 +1690,11 @@
 		return RESULT_SUCCESS;
 	} else if (argc == 2) {
 		/* one argument: look for info on the specified channel */
-		c = ast_get_channel_by_name_locked(argv[1]);
-		if (c) {
+		if ((c = ast_channel_get_by_name(argv[1]))) {
 			/* we have a matching channel */
-			ast_softhangup(c,AST_SOFTHANGUP_EXPLICIT);
+			ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
+			c = ast_channel_unref(c);
 			ast_agi_send(agi->fd, chan, "200 result=1\n");
-			ast_channel_unlock(c);
 			return RESULT_SUCCESS;
 		}
 		/* if we get this far no channel name matched the argument given */
@@ -1762,10 +1776,9 @@
 		return RESULT_SUCCESS;
 	} else if (argc == 3) {
 		/* one argument: look for info on the specified channel */
-		c = ast_get_channel_by_name_locked(argv[2]);
-		if (c) {
+		if ((c = ast_channel_get_by_name(argv[2]))) {
 			ast_agi_send(agi->fd, chan, "200 result=%d\n", c->_state);
-			ast_channel_unlock(c);
+			c = ast_channel_unref(c);
 			return RESULT_SUCCESS;
 		}
 		/* if we get this far no channel name matched the argument given */
@@ -1816,18 +1829,22 @@
 	if ((argc != 4) && (argc != 5))
 		return RESULT_SHOWUSAGE;
 	if (argc == 5) {
-		chan2 = ast_get_channel_by_name_locked(argv[4]);
+		chan2 = ast_channel_get_by_name(argv[4]);
 	} else {
 		chan2 = chan;
 	}
+
 	if (chan2) {
 		pbx_substitute_variables_helper(chan2, argv[3], tmp, sizeof(tmp) - 1);
 		ast_agi_send(agi->fd, chan, "200 result=1 (%s)\n", tmp);
 	} else {
 		ast_agi_send(agi->fd, chan, "200 result=0\n");
 	}
-	if (chan2 && (chan2 != chan))
-		ast_channel_unlock(chan2);
+
+	if (chan2 && (chan2 != chan)) {
+		chan2 = ast_channel_unref(chan2);
+	}
+
 	return RESULT_SUCCESS;
 }
 

Modified: team/russell/ast_channel_ao2/res/res_clioriginate.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/res/res_clioriginate.c?view=diff&rev=174083&r1=174082&r2=174083
==============================================================================
--- team/russell/ast_channel_ao2/res/res_clioriginate.c (original)
+++ team/russell/ast_channel_ao2/res/res_clioriginate.c Fri Feb  6 17:36:34 2009
@@ -201,15 +201,15 @@
 	name = a->argv[2];
 	dest = a->argv[3];
 
-	chan = ast_get_channel_by_name_locked(name);
-	if (!chan) {
+	if (!(chan = ast_channel_get_by_name(name))) {
 		ast_cli(a->fd, "Channel '%s' not found\n", name);
 		return CLI_FAILURE;
 	}
 
+	ast_channel_lock(chan);
 	res = ast_async_parseable_goto(chan, dest);
-
 	ast_channel_unlock(chan);
+	chan = ast_channel_unref(chan);
 
 	if (!res) {
 		ast_cli(a->fd, "Channel '%s' successfully redirected to %s\n", name, dest);




More information about the asterisk-commits mailing list