[asterisk-commits] snuffy: branch snuffy/ao2_jabber_take2 r173659 - in /team/snuffy/ao2_jabber_t...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Feb 5 14:06:38 CST 2009


Author: snuffy
Date: Thu Feb  5 14:06:38 2009
New Revision: 173659

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=173659
Log:
Update add some review board fixes
Including some ao2_callbacks

Modified:
    team/snuffy/ao2_jabber_take2/channels/chan_gtalk.c
    team/snuffy/ao2_jabber_take2/channels/chan_jingle.c
    team/snuffy/ao2_jabber_take2/res/res_jabber.c

Modified: team/snuffy/ao2_jabber_take2/channels/chan_gtalk.c
URL: http://svn.digium.com/svn-view/asterisk/team/snuffy/ao2_jabber_take2/channels/chan_gtalk.c?view=diff&rev=173659&r1=173658&r2=173659
==============================================================================
--- team/snuffy/ao2_jabber_take2/channels/chan_gtalk.c (original)
+++ team/snuffy/ao2_jabber_take2/channels/chan_gtalk.c Thu Feb  5 14:06:38 2009
@@ -44,13 +44,9 @@
 #include <iksemel.h>
 #include <pthread.h>
 
-#include "asterisk/lock.h"
 #include "asterisk/channel.h"
-#include "asterisk/config.h"
 #include "asterisk/module.h"
 #include "asterisk/pbx.h"
-#include "asterisk/sched.h"
-#include "asterisk/io.h"
 #include "asterisk/rtp.h"
 #include "asterisk/acl.h"
 #include "asterisk/callerid.h"
@@ -59,8 +55,6 @@
 #include "asterisk/app.h"
 #include "asterisk/musiconhold.h"
 #include "asterisk/manager.h"
-#include "asterisk/stringfields.h"
-#include "asterisk/utils.h"
 #include "asterisk/causes.h"
 #include "asterisk/astobj.h"
 #include "asterisk/abstract_jb.h"
@@ -188,6 +182,9 @@
 							   struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active);
 static enum ast_rtp_get_result gtalk_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp);
 static int gtalk_get_codec(struct ast_channel *chan);
+static int gtalk_update_cb(void *clients, void *args, int flags);
+static int gtalk_parser(void *data, ikspak *pak);
+
 
 /*! \brief PBX interface structure for channel registration */
 static const struct ast_channel_tech gtalk_tech = {
@@ -908,6 +905,7 @@
 		if (resources) {
 			snprintf(idroster, sizeof(idroster), "%s/%s", them, resources->resource);
 			if (buddy) {
+				/* We only needed this buddy ref to extract resource name */
 				ao2_t_ref(buddy, -1, "gtalk_alloc");
 			}
 		} else {
@@ -1752,6 +1750,21 @@
 	}
 	ASTOBJ_UNREF(client, gtalk_member_destroy);
 	return IKS_FILTER_EAT;
+}
+
+static int gtalk_update_cb(void *data, void *args, int flags) {
+	struct gtalk *member = args;
+	struct aji_client *c = data;
+
+	ao2_lock(c);
+	ASTOBJ_WRLOCK(member);
+	member->connection = NULL;
+	iks_filter_add_rule(c->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://www.google.com/session", IKS_RULE_DONE);
+	iks_filter_add_rule(c->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://jabber.org/protocol/gtalk", IKS_RULE_DONE);
+	ASTOBJ_UNLOCK(member);
+	ao2_unlock(c);
+
+	return 0;
 }
 
 /* Not using this anymore probably take out soon 
@@ -1967,20 +1980,8 @@
 				ASTOBJ_UNLOCK(member);
 				clients = ast_aji_get_clients();
 				if (clients) {
-					struct ao2_iterator iter;
-					struct aji_client *c;
-
-					iter = ao2_iterator_init(clients, 0);
-					while ((c =ao2_t_iterator_next(&iter,"iter clients"))) {
-						ao2_lock(c);
-						ASTOBJ_WRLOCK(member);
-						member->connection = NULL;
-						iks_filter_add_rule(c->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://www.google.com/session", IKS_RULE_DONE);
-						iks_filter_add_rule(c->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://jabber.org/protocol/gtalk", IKS_RULE_DONE);
-						ASTOBJ_UNLOCK(member);
-						ao2_unlock(c);
-						ao2_ref(c, -1);
-					}
+					ao2_t_callback(clients, 0, gtalk_update_cb, member, "stuff");
+					
 					ASTOBJ_CONTAINER_LINK(&gtalk_list, member);
 					ASTOBJ_UNREF(member, gtalk_member_destroy);
 				} else {

Modified: team/snuffy/ao2_jabber_take2/channels/chan_jingle.c
URL: http://svn.digium.com/svn-view/asterisk/team/snuffy/ao2_jabber_take2/channels/chan_jingle.c?view=diff&rev=173659&r1=173658&r2=173659
==============================================================================
--- team/snuffy/ao2_jabber_take2/channels/chan_jingle.c (original)
+++ team/snuffy/ao2_jabber_take2/channels/chan_jingle.c Thu Feb  5 14:06:38 2009
@@ -189,6 +189,8 @@
 							   struct ast_rtp *vrtp, struct ast_rtp *tpeer, int codecs, int nat_active);
 static enum ast_rtp_get_result jingle_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp);
 static int jingle_get_codec(struct ast_channel *chan);
+static int jingle_update_cb(void *clients, void *args, int flags);
+static int jingle_parser(void *data, ikspak *pak);
 
 /*! \brief PBX interface structure for channel registration */
 static const struct ast_channel_tech jingle_tech = {
@@ -421,6 +423,22 @@
 {
 	struct jingle_pvt *p = chan->tech_pvt;
 	return p->peercapability;
+}
+
+static int jingle_update_cb(void *data, void *args, int flags) {
+	struct jingle *member = args;
+	struct aji_client *c = data;
+
+	ao2_lock(c);
+	ASTOBJ_WRLOCK(member);
+	member->connection = NULL;
+	iks_filter_add_rule(c->f, jingle_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, JINGLE_NS, IKS_RULE_DONE);
+	iks_filter_add_rule(c->f, jingle_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, JINGLE_DTMF_NS, IKS_RULE_DONE);
+	ASTOBJ_UNLOCK(member);
+	ao2_unlock(c);
+	ao2_ref(c, -1);
+
+	return 0;
 }
 
 static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, struct ast_rtp *tpeer, int codecs, int nat_active)
@@ -1825,21 +1843,10 @@
 				ASTOBJ_UNLOCK(member);
 				clients = ast_aji_get_clients();
 				if (clients) {
-					struct ao2_iterator iter;
-					struct aji_client *c;
-					
-					iter = ao2_iterator_init(clients, 0);
-					while ((c = ao2_t_iterator_next(&iter,"client iter"))) {
-						ao2_lock(c);
-						ASTOBJ_WRLOCK(member);
-						member->connection = NULL;
-						iks_filter_add_rule(c->f, jingle_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS,	JINGLE_NS, IKS_RULE_DONE);
-						iks_filter_add_rule(c->f, jingle_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS,	JINGLE_DTMF_NS, IKS_RULE_DONE);
-						ASTOBJ_UNLOCK(member);
-						ao2_unlock(c);
-						ao2_ref(c, -1);
-					}
+					ao2_t_callback(clients, 0, jingle_update_cb, member, "stuff");
+
 					ASTOBJ_CONTAINER_LINK(&jingle_list, member);
+					ASTOBJ_UNREF(member, jingle_member_destroy); /* missing? */
 				} else {
 					ASTOBJ_UNLOCK(member);
 					ASTOBJ_UNREF(member, jingle_member_destroy);

Modified: team/snuffy/ao2_jabber_take2/res/res_jabber.c
URL: http://svn.digium.com/svn-view/asterisk/team/snuffy/ao2_jabber_take2/res/res_jabber.c?view=diff&rev=173659&r1=173658&r2=173659
==============================================================================
--- team/snuffy/ao2_jabber_take2/res/res_jabber.c (original)
+++ team/snuffy/ao2_jabber_take2/res/res_jabber.c Thu Feb  5 14:06:38 2009
@@ -45,17 +45,13 @@
 #include "asterisk/channel.h"
 #include "asterisk/jabber.h"
 #include "asterisk/file.h"
-#include "asterisk/config.h"
 #include "asterisk/callerid.h"
-#include "asterisk/lock.h"
 #include "asterisk/cli.h"
 #include "asterisk/app.h"
 #include "asterisk/pbx.h"
 #include "asterisk/md5.h"
 #include "asterisk/acl.h"
-#include "asterisk/utils.h"
 #include "asterisk/module.h"
-/*#include "asterisk/astobj.h"*/
 #include "asterisk/astobj2.h"
 #include "asterisk/astdb.h"
 #include "asterisk/manager.h"
@@ -290,15 +286,6 @@
 {
 	struct aji_client *c = obj;
 	struct aji_message *tmp;
-	struct aji_buddy *b;
-	struct ao2_iterator biter;
-	
-	biter = ao2_iterator_init(c->buddies, 0);
-
-	while ((b = ao2_t_iterator_next(&biter, "iterate thru buddies"))) {
-		ao2_t_unlink(c->buddies, b, "Remove buddy from list");
-		buddy_unref(b, "unref buddy");
-	}
 	
 	iks_filter_delete(c->f);
 	iks_parser_delete(c->p);
@@ -312,6 +299,7 @@
 	}
 	AST_LIST_HEAD_DESTROY(&c->messages);
 
+	ao2_t_ref(c->buddies, -1, "unlink buddies from list");
 	ao2_lock(clients); /* required locking for removal? */
 	ao2_t_unlink(clients, c, "Remove client from list");
 	ao2_unlock(clients);
@@ -2797,7 +2785,7 @@
 	char *resource;
 	struct aji_client *client = NULL;
 	struct aji_client tmp_client;
-	struct aji_buddy *b = NULL;
+	struct aji_buddy *buddy = NULL;
 	struct ao2_iterator biter;
 	int flag = 0;
 
@@ -2820,11 +2808,11 @@
 	}
 	/*ASTOBJ_CONTAINER_MARKALL(&client->buddies); */
 	biter = ao2_iterator_init(client->buddies, 0);
-	while (( b = ao2_t_iterator_next(&biter, "Iter buddies"))) {
+	while (( buddy = ao2_t_iterator_next(&biter, "Iter buddies"))) {
 		ao2_lock(b);
-		b->mark = 1;
-		ao2_unlock(b);
-		buddy_unref(b, "unref buddy");
+		buddy->mark = 1;
+		ao2_unlock(buddy);
+		buddy_unref(buddy, "unref buddy");
 	}
 
 




More information about the asterisk-commits mailing list