[asterisk-commits] eliel: branch group/data_api_gsoc2009 r206190 - /team/group/data_api_gsoc2009...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 13 12:17:13 CDT 2009


Author: eliel
Date: Mon Jul 13 12:17:10 2009
New Revision: 206190

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=206190
Log:
Do not create nodes if they are empty!


Modified:
    team/group/data_api_gsoc2009/apps/app_queue.c

Modified: team/group/data_api_gsoc2009/apps/app_queue.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/apps/app_queue.c?view=diff&rev=206190&r1=206189&r2=206190
==============================================================================
--- team/group/data_api_gsoc2009/apps/app_queue.c (original)
+++ team/group/data_api_gsoc2009/apps/app_queue.c Mon Jul 13 12:17:10 2009
@@ -7483,7 +7483,7 @@
 	struct ao2_iterator i, im;
 	struct call_queue *queue;
 	struct member *member;
-	struct ast_data *data_root, *data_queue, *data_member, *data_members;
+	struct ast_data *data_root, *data_queue = NULL, *data_member, *data_members = NULL;
 	int member_added;
 
 	data_root = ast_data_create("queues");
@@ -7504,41 +7504,41 @@
 			continue;
 		}
 
-
-		data_queue = ast_data_add_node(data_root, "queue");
-		if (!data_queue) {
-			ao2_unlock(queue);
-			queue_unref(queue);
-			continue;
-		}
-
 		member_added = 1;
 		if (queue->members) {
-			data_members = ast_data_add_node(data_queue, "members");
-			if (!data_members) {
-				ao2_unlock(queue);
-				queue_unref(queue);
-				continue;
-			}
-
 			member_added = 0;
 			im = ao2_iterator_init(queue->members, 0);
 			while ((member = ao2_iterator_next(&im))) {
+				/* compare the member structure. */
+				if (ast_data_search_cmp_structure(search, member, member, "queues/queue/members/member")) {
+					ao2_ref(member, -1);
+					continue;
+				}
+
+				if (!data_queue) {
+					data_queue = ast_data_add_node(data_root, "queue");
+					if (!data_queue) {
+						ao2_unlock(queue);
+						queue_unref(queue);
+						continue;
+					}
+				}
+
+				if (!data_members) {
+					data_members = ast_data_add_node(data_queue, "members");
+					if (!data_members) {
+						ao2_unlock(queue);
+						queue_unref(queue);
+						continue;
+					}
+				}
+
 				data_member = ast_data_add_node(data_members, "member");
 				if (!data_member) {
 					ao2_ref(member, -1);
 					continue;
 				}
 
-				/* compare the member structure. */
-				if (ast_data_search_cmp_structure(search, member, member, "queues/queue/members/member")) {
-					ast_log(LOG_ERROR, "Member %s doesn't match!\n", member->interface);
-					ao2_ref(member, -1);
-					continue;
-				} else {
-					ast_log(LOG_ERROR, "We have a match! %s\n", member->interface);
-				}
-
 				ast_data_add_structure(member, data_member, member);
 				member_added = 1;
 				ao2_ref(member, -1);
@@ -7547,7 +7547,10 @@
 		if (member_added) {
 			ast_data_add_structure(call_queue, data_queue, queue); 
 		}
-	
+
+		data_queue = NULL;
+		data_members = NULL;
+
 		ao2_unlock(queue);
 		queue_unref(queue);
 	}




More information about the asterisk-commits mailing list