[asterisk-commits] rizzo: branch rizzo/astobj2 r47355 - /team/rizzo/astobj2/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Nov 9 02:55:12 MST 2006


Author: rizzo
Date: Thu Nov  9 03:55:11 2006
New Revision: 47355

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47355
Log:
remember to allocate the container at the beginning.


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=47355&r1=47354&r2=47355
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Thu Nov  9 03:55:11 2006
@@ -996,7 +996,7 @@
 // #define	USE_AO2
 #ifdef	USE_AO2	/* astobj2 implementation */
 #include "asterisk/astobj2.h"
-ao2_container *dialoglist;
+ao2_container *dialogs;
 
 /* we never need to lock these */
 static void dialoglist_lock(void)
@@ -3017,7 +3017,7 @@
 static void sip_pvt_unlink(struct sip_pvt *p)
 {
 #ifdef USE_AO2
-	ao2_unlink(dialoglist, p);
+	ao2_unlink(dialogs, p);
 #else
 	struct sip_pvt *cur, *prev = NULL;
 
@@ -4419,7 +4419,7 @@
 
 	/* Add to active dialog list */
 #ifdef USE_AO2
-	ao2_link(dialoglist, p);
+	ao2_link(dialogs, p);
 #else
 	dialoglist_lock();
 	p->next = dialoglist;
@@ -4522,7 +4522,7 @@
 	if (profile_id == -1)
 		profile_id = ast_add_profile("find_call", 0);
 #ifdef USE_AO2
-	p = ao2_callback(dialoglist, OBJ_DATA, find_call_cb, &arg);
+	p = ao2_callback(dialogs, 0 /* single, data */, find_call_cb, &arg);
 	if (p) {
 		sip_pvt_lock(p);
 		return p;
@@ -8724,7 +8724,7 @@
 	/* Search dialogs and find the match */
 	dialoglist_lock();
 #ifdef USE_AO2
-	sip_pvt_ptr = ao2_callback(dialoglist, OBJ_DATA, find_pvt_byid_cb, &arg);
+	sip_pvt_ptr = ao2_callback(dialogs, 0 /* single, data */, find_pvt_byid_cb, &arg);
 #else
 	for (sip_pvt_ptr = dialoglist; sip_pvt_ptr; sip_pvt_ptr = sip_pvt_ptr->next) {
 		if (find_pvt_byid_cb(sip_pvt_ptr, &arg, 0))
@@ -10657,7 +10657,7 @@
 	dialoglist_lock();
 #ifdef USE_AO2
 	cur = NULL;	/* silence compiler */
-        ao2_callback(dialoglist, 0, show_chanannels_cb, &arg);
+        ao2_callback(dialogs, OBJ_MULTIPLE|OBJ_NODATA, show_chanannels_cb, &arg);
 #else
 	for (cur = dialoglist; cur; cur = cur->next) {
 		show_chanannels_cb(cur, &arg, 0);
@@ -10683,7 +10683,7 @@
 	int wordlen = strlen(word);
 
 #ifdef USE_AO2
-	ao2_iterator i = ao2_iterator_init(dialoglist, 0);
+	ao2_iterator i = ao2_iterator_init(dialogs, 0);
 	while ( (cur = ao2_iterator_next(&i)) ) {
 		if (!strncasecmp(word, cur->callid, wordlen) && ++which > state) {
 			c = ast_strdup(cur->callid);
@@ -10904,7 +10904,7 @@
 	dialoglist_lock();
 #ifdef USE_AO2
     {
-	ao2_iterator i = ao2_iterator_init(dialoglist, 0);
+	ao2_iterator i = ao2_iterator_init(dialogs, 0);
 	while ( (cur = ao2_iterator_next(&i)) ) {
 		show_channel_cb(cur, &arg);
 		ao2_ref(cur, -1);
@@ -10960,7 +10960,7 @@
 	dialoglist_lock();
 #ifdef USE_AO2
     {
-	ao2_iterator i = ao2_iterator_init(dialoglist, 0);
+	ao2_iterator i = ao2_iterator_init(dialogs, 0);
 	while ( (cur = ao2_iterator_next(&i)) ) {
 		show_history_cb(cur, &arg);
 		ao2_ref(cur, -1);
@@ -14606,7 +14606,7 @@
 
 #ifdef USE_AO2
 		/* XXX we should really use a callback here */
-			ao2_iterator i = ao2_iterator_init(dialoglist, 0);
+			ao2_iterator i = ao2_iterator_init(dialogs, 0);
 			while ((p_old = ao2_iterator_next(&i))) {
 				if (p_old == p ||
 				    p_old->initreq.method != SIP_SUBSCRIBE ||
@@ -15156,7 +15156,7 @@
 #ifdef USE_AO2
 	/* XXX should really use a callback here */
 	{
-			ao2_iterator i = ao2_iterator_init(dialoglist, 0);
+			ao2_iterator i = ao2_iterator_init(dialogs, 0);
 
 			prev = NULL;	/* silence compiler */
 			while ((cur = ao2_iterator_next(&i))) {
@@ -15164,7 +15164,7 @@
 				check_rtp_timeout(cur, t);
 				if (ast_test_flag(&cur->flags[0], SIP_NEEDDESTROY) && !cur->packets && !cur->owner) {
 					sip_pvt_unlock(cur);
-					ao2_unlink(dialoglist, cur);
+					ao2_unlink(dialogs, cur);
 					ao2_ref(cur, -1);
 					__sip_destroy(cur);
 				} else
@@ -17440,6 +17440,9 @@
 	ASTOBJ_CONTAINER_INIT(&peerl);	/* Peer object list */
 	ASTOBJ_CONTAINER_INIT(&regl);	/* Registry object list */
 
+#ifdef USE_AO2
+	dialogs = ao2_container_alloc(100, NULL /* no hash */, NULL /* no cmp */);
+#endif
 	if (!(sched = sched_context_create())) {
 		ast_log(LOG_ERROR, "Unable to create scheduler context\n");
 		return AST_MODULE_LOAD_FAILURE;
@@ -17531,7 +17534,7 @@
 
 #ifdef USE_AO2
 	{
-		ao2_iterator i = ao2_iterator_init(dialoglist, 0);
+		ao2_iterator i = ao2_iterator_init(dialogs, 0);
 		while ((p = ao2_iterator_next(&i))) {
 			if (p->owner)
 				ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
@@ -17559,8 +17562,8 @@
 
 #ifdef USE_AO2
 	pl = NULL;	/* XXX silence compiler */
-	ao2_ref(dialoglist, -1);
-	dialoglist = NULL;
+	ao2_ref(dialogs, -1);
+	dialogs = NULL;
 #else
 	dialoglist_lock();
 	/* Destroy all the dialogs and free their memory */



More information about the asterisk-commits mailing list