[asterisk-commits] russell: branch russell/ast_channel_refcount r82295 - in /team/russell/ast_ch...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 12 16:55:54 CDT 2007


Author: russell
Date: Wed Sep 12 16:55:54 2007
New Revision: 82295

URL: http://svn.digium.com/view/asterisk?view=rev&rev=82295
Log:
convert res_agi to the new functions

Modified:
    team/russell/ast_channel_refcount/include/asterisk/channel.h
    team/russell/ast_channel_refcount/main/channel.c
    team/russell/ast_channel_refcount/res/res_agi.c

Modified: team/russell/ast_channel_refcount/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/russell/ast_channel_refcount/include/asterisk/channel.h?view=diff&rev=82295&r1=82294&r2=82295
==============================================================================
--- team/russell/ast_channel_refcount/include/asterisk/channel.h (original)
+++ team/russell/ast_channel_refcount/include/asterisk/channel.h Wed Sep 12 16:55:54 2007
@@ -907,6 +907,7 @@
  */
 char *ast_recvtext(struct ast_channel *chan, int timeout);
 
+#if 0
 /*! \brief Browse channels in use
  * Browse the channels currently in use 
  * \param prev where you want to start in the channel list
@@ -930,6 +931,7 @@
 /*! \brief Get next channel by exten (and optionally context) and lock it */
 struct ast_channel *ast_walk_channel_by_exten_locked(const struct ast_channel *chan, const char *exten,
 						     const char *context);
+#endif
 
 /*! ! \brief Waits for a digit
  * \param c channel to wait for a digit on
@@ -1382,23 +1384,42 @@
 #define ast_channel_unlock(c) ao2_unlock(c)
 #define ast_channel_trylock(c) ao2_trylock(c)
 
+static force_inline struct ast_channel *ast_channel_ref(struct ast_channel *chan)
+{
+	ao2_ref(chan, +1);
+	return chan;
+}
+
+static force_inline struct ast_channel *ast_channel_unref(struct ast_channel *chan)
+{
+	ao2_ref(chan, -1);
+	return NULL;
+}
+
+/* 
+ * \brief A channel iterator
+ *
+ * This is an opaque type.
+ */
+struct ast_channel_iterator;
+
 struct ast_channel_iterator *ast_channel_iterator_destroy(struct ast_channel_iterator *i);
 
-struct ast_channel_iterator *ast_channel_iterator_byexten_new(const char *exten, 
+struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, 
 	const char *context);
 
-struct ast_channel_iterator *ast_channel_iterator_byname_new(const char *name, 
+struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name, 
 	size_t name_len);
 
 struct ast_channel_iterator *ast_channel_iterator_all_new(void);
 
 struct ast_channel *ast_channel_iterator_next(struct ast_channel_iterator *i);
 
-struct ast_channel *ast_channel_get_byname(const char *name);
-
-struct ast_channel *ast_channel_get_byname_prefix(const char *name, size_t name_len);
-
-struct ast_channel *ast_channel_get_byexten(const char *exten, const char *context);
+struct ast_channel *ast_channel_get_by_name(const char *name);
+
+struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len);
+
+struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: team/russell/ast_channel_refcount/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_channel_refcount/main/channel.c?view=diff&rev=82295&r1=82294&r2=82295
==============================================================================
--- team/russell/ast_channel_refcount/main/channel.c (original)
+++ team/russell/ast_channel_refcount/main/channel.c Wed Sep 12 16:55:54 2007
@@ -715,18 +715,6 @@
 	.description = "Null channel (should not see this)",
 };
 
-static inline struct ast_channel *ast_channel_ref(struct ast_channel *chan)
-{
-	ao2_ref(chan, +1);
-	return chan;
-}
-
-static inline struct ast_channel *ast_channel_unref(struct ast_channel *chan)
-{
-	ao2_ref(chan, -1);
-	return NULL;
-}
-
 static void free_cid(struct ast_callerid *cid)
 {
 	if (cid->cid_dnid)
@@ -1288,13 +1276,13 @@
 	return NULL;
 }
 
-struct ast_channel_iterator *ast_channel_iterator_byexten_new(const char *exten, 
+struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, 
 	const char *context)
 {
 	return ast_channel_iterator_new(NULL, 0, exten, context);
 }
 
-struct ast_channel_iterator *ast_channel_iterator_byname_new(const char *name, 
+struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name, 
 	size_t name_len)
 {
 	return ast_channel_iterator_new(name, name_len, NULL, NULL);
@@ -1348,17 +1336,17 @@
 	return ao2_find(channels, &tmp_chan, OBJ_POINTER);
 }
 
-struct ast_channel *ast_channel_get_byname(const char *name)
+struct ast_channel *ast_channel_get_by_name(const char *name)
 {
 	return ast_channel_get_full(name, 0, NULL, NULL);
 }
 
-struct ast_channel *ast_channel_get_byname_prefix(const char *name, size_t name_len)
+struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len)
 {
 	return ast_channel_get_full(name, name_len, NULL, NULL);
 }
 
-struct ast_channel *ast_channel_get_byexten(const char *exten, const char *context)
+struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context)
 {
 	return ast_channel_get_full(NULL, 0, exten, context);
 }

Modified: team/russell/ast_channel_refcount/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_channel_refcount/res/res_agi.c?view=diff&rev=82295&r1=82294&r2=82295
==============================================================================
--- team/russell/ast_channel_refcount/res/res_agi.c (original)
+++ team/russell/ast_channel_refcount/res/res_agi.c Wed Sep 12 16:55:54 2007
@@ -1075,12 +1075,12 @@
 		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]);
+		c = ast_channel_get_by_name(argv[1]);	
 		if (c) {
 			/* we have a matching channel */
-			ast_softhangup(c,AST_SOFTHANGUP_EXPLICIT);
+			ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
 			fdprintf(agi->fd, "200 result=1\n");
-			ast_channel_unlock(c);
+			c = ast_channel_unref(c);
 			return RESULT_SUCCESS;
 		}
 		/* if we get this far no channel name matched the argument given */
@@ -1146,10 +1146,10 @@
 		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]);
+		c = ast_channel_get_by_name(argv[2]);
 		if (c) {
 			fdprintf(agi->fd, "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 */
@@ -1195,23 +1195,25 @@
 static int handle_getvariablefull(struct ast_channel *chan, AGI *agi, int argc, char **argv)
 {
 	char tmp[4096] = "";
-	struct ast_channel *chan2=NULL;
+	struct ast_channel *chan2 = NULL;
 
 	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 (chan) { /* XXX isn't this chan2 ? */
+		ast_channel_lock(chan2);
 		pbx_substitute_variables_helper(chan2, argv[3], tmp, sizeof(tmp) - 1);
+		ast_channel_unlock(chan2);
 		fdprintf(agi->fd, "200 result=1 (%s)\n", tmp);
 	} else {
 		fdprintf(agi->fd, "200 result=0\n");
 	}
 	if (chan2 && (chan2 != chan))
-		ast_channel_unlock(chan2);
+		ast_channel_unref(chan2);
 	return RESULT_SUCCESS;
 }
 




More information about the asterisk-commits mailing list