[asterisk-commits] mmichelson: branch mmichelson/queue-reset r101125 - /team/mmichelson/queue-re...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 29 18:42:38 CST 2008


Author: mmichelson
Date: Tue Jan 29 18:42:37 2008
New Revision: 101125

URL: http://svn.digium.com/view/asterisk?view=rev&rev=101125
Log:
Two changes:

1. Move membercount changes to the member reloading area and out of queue initialization since
   it should only be affected if reloading members.
2. Remove my quick reload of a single queue since the logic was off. 


Modified:
    team/mmichelson/queue-reset/apps/app_queue.c

Modified: team/mmichelson/queue-reset/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/apps/app_queue.c?view=diff&rev=101125&r1=101124&r2=101125
==============================================================================
--- team/mmichelson/queue-reset/apps/app_queue.c (original)
+++ team/mmichelson/queue-reset/apps/app_queue.c Tue Jan 29 18:42:37 2008
@@ -922,7 +922,6 @@
 		else
 			q->members = ao2_container_alloc(37, member_hash_fn, member_cmp_fn);
 	}
-	q->membercount = 0;
 	q->found = 1;
 
 	ast_string_field_set(q, sound_next, "queue-youarenext");
@@ -1433,6 +1432,7 @@
 		ao2_lock(q);
 		clear_queue(q);
 		q->realtime = 1;
+		q->membercount = 0;
 		init_queue(q);		/* Ensure defaults for all parameters not set explicitly. */
 		ao2_link(queues, q);
 	}
@@ -5059,6 +5059,7 @@
 		init_queue(q);
 	}
 	if (member_reload) {
+		q->membercount = 0;
 		mem_iter = ao2_iterator_init(q->members, 0);
 		while ((cur = ao2_iterator_next(&mem_iter))) {
 			if (!cur->dynamic)
@@ -5087,7 +5088,10 @@
 	if (member_reload) {
 		mem_iter = ao2_iterator_init(q->members, 0);
 		while ((cur = ao2_iterator_next(&mem_iter))) {
-			if (! cur->delme) {
+			if (!cur->delme) {
+				if (cur->dynamic)
+					q->membercount++;
+				cur->status = ast_device_state(cur->interface);
 				ao2_ref(cur, -1);
 				continue;
 			}
@@ -5121,15 +5125,7 @@
 		return 0;
 	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
 		return 0;
-	/* Quick reload if only one queue is being reloaded */
-	if (!ast_strlen_zero(queuename)) {
-		if (!ast_category_exist(cfg, queuename)) {
-			ast_log(LOG_WARNING, "Request for reload on non-existent queue '%s'. Aborting!\n", queuename);
-			return AST_MODULE_LOAD_SUCCESS;
-		}
-		reload_single_queue(cfg, mask, queuename);
-		return AST_MODULE_LOAD_SUCCESS;
-	}
+
 	/* We've made it here, so it looks like we're doing operations on all queues. */
 	ao2_lock(queues);
 	
@@ -5140,7 +5136,7 @@
 		queue_iter = ao2_iterator_init(queues, F_AO2I_DONTLOCK);
 		while ((q = ao2_iterator_next(&queue_iter))) {
 			/* We don't want to affect realtime queues at all during a reload */
-			if (!q->realtime) {
+			if (!q->realtime && (ast_strlen_zero(queuename) || !strcasecmp(queuename, q->name))) {
 				q->dead = 1;
 				q->found = 0;
 			}
@@ -5155,7 +5151,8 @@
 			queue_set_global_params(cfg);
 			continue;
 		}
-		reload_single_queue(cfg, mask, cat);
+		if (ast_strlen_zero(queuename) || !strcasecmp(cat, queuename))
+			reload_single_queue(cfg, mask, cat);
 	}
 	
 	ast_config_destroy(cfg);
@@ -5163,19 +5160,9 @@
 	if (mask & QUEUE_RELOAD) {
 		queue_iter = ao2_iterator_init(queues, 0);
 		while ((q = ao2_iterator_next(&queue_iter))) {
-			if (q->dead) {
+			if ((ast_strlen_zero(queuname) || !strcasecmp(queuename, q->name)) && q->dead) {
 				ao2_unlink(queues, q);
-			} else {
-				ao2_lock(q);
-				mem_iter = ao2_iterator_init(q->members, 0);
-				while ((cur = ao2_iterator_next(&mem_iter))) {
-					if (cur->dynamic)
-						q->membercount++;
-					cur->status = ast_device_state(cur->interface);
-					ao2_ref(cur, -1);
-				}
-				ao2_unlock(q);
-			}
+			} 
 			queue_unref(q);
 		}
 	}




More information about the asterisk-commits mailing list