[Asterisk-code-review] app queue: Update dynamic members ringinuse on reload. (asterisk[master])

Etienne Lessard asteriskteam at digium.com
Fri Sep 9 13:07:24 CDT 2016


Etienne Lessard has uploaded a new change for review.

  https://gerrit.asterisk.org/3874

Change subject: app_queue: Update dynamic members ringinuse on reload.
......................................................................

app_queue: Update dynamic members ringinuse on reload.

Previously, when reloading the members of a queue, the members added statically
(i.e. defined in queues.conf) would see their "ringinuse" value updated but not
the members added dynamically.

This change makes dynamic members ringuse value to be updated on reload.

Note that it's impossible to add a dynamic member with a specific ringinuse
value. For both static and dynamic members, the ringinuse value can always be
changed later on with command like "queue set ringinuse" or with the AMI action
"QueueMemberRingInUse". So it's possible this commit could break a user workflow
if he was changing the ringinuse value of dynamic members via such commands and
was also relying on the fact that a queue reload would not update the dynamic
members ringinuse value.

ASTERISK-26330

Change-Id: I3745cc9a06ba7e02c399636f1ee9e58c04081f3f
---
M apps/app_queue.c
1 file changed, 17 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/74/3874/1

diff --git a/apps/app_queue.c b/apps/app_queue.c
index f9dd86b..0652e22 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -7154,7 +7154,6 @@
 	ao2_lock(q);
 	if ((old_member = interface_exists(q, interface)) == NULL) {
 		if ((new_member = create_queue_member(interface, membername, penalty, paused, state_interface, q->ringinuse))) {
-			new_member->ringinuse = q->ringinuse;
 			new_member->dynamic = 1;
 			if (reason_paused) {
 				ast_copy_string(new_member->reason_paused, reason_paused, sizeof(new_member->reason_paused));
@@ -9041,6 +9040,7 @@
 {
 	int new;
 	struct call_queue *q = NULL;
+	struct member *member;
 	/*We're defining a queue*/
 	struct call_queue tmpq = {
 		.name = queuename,
@@ -9050,6 +9050,8 @@
 	const int member_reload = ast_test_flag(mask, QUEUE_RELOAD_MEMBER);
 	int prev_weight = 0;
 	struct ast_variable *var;
+	struct ao2_iterator mem_iter;
+
 	if (!(q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Find queue for reload"))) {
 		if (queue_reload) {
 			/* Make one then */
@@ -9118,6 +9120,20 @@
 		}
 	}
 
+	/* Update ringinuse for dynamic members */
+	if (member_reload) {
+		ao2_lock(q->members);
+		mem_iter = ao2_iterator_init(q->members, AO2_ITERATOR_DONTLOCK);
+		while ((member = ao2_iterator_next(&mem_iter))) {
+			if (member->dynamic) {
+				member->ringinuse = q->ringinuse;
+			}
+			ao2_ref(member, -1);
+		}
+		ao2_iterator_destroy(&mem_iter);
+		ao2_unlock(q->members);
+	}
+
 	/* At this point, we've determined if the queue has a weight, so update use_weight
 	 * as appropriate
 	 */

-- 
To view, visit https://gerrit.asterisk.org/3874
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3745cc9a06ba7e02c399636f1ee9e58c04081f3f
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Etienne Lessard <elessard at proformatique.com>



More information about the asterisk-code-review mailing list