[asterisk-commits] dvossel: branch dvossel/sip_resource_list_trunk r186681 - /team/dvossel/sip_r...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 6 14:39:59 CDT 2009


Author: dvossel
Date: Mon Apr  6 14:39:55 2009
New Revision: 186681

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=186681
Log:
Fixing a few issues with rlist_build().  Making sure to decrement refs and fixed issue with duplicate items linked into table.  Now that resource lists are built and stored correctly I will on to handling rlist subscriptions and notifications... probably incorrectly. 

Modified:
    team/dvossel/sip_resource_list_trunk/channels/chan_sip.c

Modified: team/dvossel/sip_resource_list_trunk/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/team/dvossel/sip_resource_list_trunk/channels/chan_sip.c?view=diff&rev=186681&r1=186680&r2=186681
==============================================================================
--- team/dvossel/sip_resource_list_trunk/channels/chan_sip.c (original)
+++ team/dvossel/sip_resource_list_trunk/channels/chan_sip.c Mon Apr  6 14:39:55 2009
@@ -23201,14 +23201,27 @@
 	if (!(resource = ast_calloc(1, sizeof(*resource)))) {
 		return -1;
 	}
-
 	ast_string_field_init(resource, 128);
 	ast_string_field_set(resource, exten, monitorexten);
-
 	AST_LIST_INSERT_TAIL(&rlist->resources, resource, entry);
 
-	ast_log(LOG_NOTICE, "ADD RESOURCE %s, to RLIST %s\n", resource->exten, rlist->name); //todohere remove
 	return 0;
+}
+
+static void print_rlist() //todohere remove
+{
+	struct sip_rlist *rlist;
+	struct sip_rlist_resource *resource;
+	struct ao2_iterator it;
+
+	it = ao2_iterator_init(rlists, 0);
+	while ((rlist = ao2_iterator_next(&it))) {
+		ast_log(LOG_NOTICE,"RESOURCE LIST: %s CONTEXT: %s the_MARK:%d\n", rlist->name, rlist->context, rlist->the_mark);
+		AST_LIST_TRAVERSE(&rlist->resources, resource, entry) {
+			ast_log(LOG_NOTICE, "\tMONITOR EXTEN: %s\n", resource->exten);
+		}
+		unref_rlist(rlist, "print_rlist");
+	}
 }
 
 static struct sip_rlist *build_rlist(const char *name, struct ast_variable *v, struct ast_variable *alt, int realtime)
@@ -23225,18 +23238,19 @@
 
 	/* does rlist already exist, if so mark as found. else create new */
 	if (rlist) {
-		destroy_rlist_resources(rlist);
+		destroy_rlist_resources(rlist); /* rlist found, remove all monitor resources and rebuild */
 		found++;
+		ast_log(LOG_NOTICE, "FOUND RLIST:%s", rlist->name); //todohere remove
 	} else {
 		if (!(rlist = ao2_t_alloc(sizeof(*rlist), sip_destroy_rlist, "allocate a rlist struct"))) {
 			return NULL;
 		}
 
 		if (ast_string_field_init(rlist, 256)) {
-			ao2_ref(rlist, -1);
+			unref_rlist(rlist, "rlist failed to init string field");
 			return NULL;
 		}
-
+;
 		ast_copy_string(rlist->name, name, sizeof(rlist->name));
 	}
 
@@ -23247,7 +23261,12 @@
 			ast_string_field_set(rlist, context, v->value);
 		}
 	}
-
+	rlist->the_mark = 0; /* unmark this resource list for deletion */
+
+	if (found) {
+		ao2_t_ref(rlist, -1, "rlist found and updated, decrement ref and return NULL");
+		return NULL;
+	}
 	return rlist;
 }
 
@@ -24534,6 +24553,9 @@
 		}
 	}
 
+//todohere remove
+	print_rlist();
+
 	/* Set UDP address and open socket */
 	bindaddr.sin_family = AF_INET;
 	internip = bindaddr;




More information about the asterisk-commits mailing list