[Asterisk-code-review] app queue: Added reason pause of member (asterisk[master])

Matt Jordan asteriskteam at digium.com
Mon Nov 2 07:59:18 CST 2015


Matt Jordan has submitted this change and it was merged.

Change subject: app_queue: Added reason pause of member
......................................................................


app_queue: Added reason pause of member

In app_queue added value Paused Reason on QueueMemberStatus when a member
on queue is paused and the reason was set.

ASTERISK-25480 #close
Reporte by: Rodrigo Ramírez Norambuena

Change-Id: Ia5db503482f50764c15e2020196c785f59d4a68e
---
M CHANGES
M apps/app_queue.c
2 files changed, 21 insertions(+), 3 deletions(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Matt Jordan: Looks good to me, approved
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/CHANGES b/CHANGES
index 88743cc..4cf1043 100644
--- a/CHANGES
+++ b/CHANGES
@@ -184,6 +184,10 @@
    names. This setting is configurable for cdr_adaptive_odbc via the
    quoted_identifiers in configuration file cdr_adaptive_odbc.conf.
 
+Queue
+-------------------
+ * Added field ReasonPause on QueueMemberStatus if set when paused, the reason
+   the queue member was paused.
 
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 13.5.0 to Asterisk 13.6.0 ------------
diff --git a/apps/app_queue.c b/apps/app_queue.c
index e043e18..862988b 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -1043,6 +1043,9 @@
 						<enum name="1"/>
 					</enumlist>
 				</parameter>
+				<parameter name="PausedReason">
+					<para>If set when paused, the reason the queue member was paused.</para>
+				</parameter>
 				<parameter name="Ringinuse">
 					<enumlist>
 						<enum name="0"/>
@@ -1534,6 +1537,7 @@
 	int realtime;                        /*!< Is this member realtime? */
 	int status;                          /*!< Status of queue member */
 	int paused;                          /*!< Are we paused (not accepting calls)? */
+	char reason_paused[80];              /*!< Reason of paused if member is paused */
 	int queuepos;                        /*!< In what order (pertains to certain strategies) should this member be called? */
 	time_t lastcall;                     /*!< When last successful call was hungup */
 	struct call_queue *lastqueue;	     /*!< Last queue we received a call */
@@ -2173,7 +2177,7 @@
 
 static struct ast_json *queue_member_blob_create(struct call_queue *q, struct member *mem)
 {
-	return ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: i, s: i, s: i, s: i, s: i, s: i}",
+	return ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: i, s: i, s: i, s: i, s: i, s: s, s: i}",
 		"Queue", q->name,
 		"MemberName", mem->membername,
 		"Interface", mem->interface,
@@ -2184,6 +2188,7 @@
 		"LastCall", (int)mem->lastcall,
 		"Status", mem->status,
 		"Paused", mem->paused,
+		"PausedReason", mem->reason_paused,
 		"Ringinuse", mem->ringinuse);
 }
 
@@ -7069,6 +7074,14 @@
 	}
 
 	mem->paused = paused;
+	if (paused) {
+		if (!ast_strlen_zero(reason)) {
+			ast_copy_string(mem->reason_paused, reason, sizeof(mem->reason_paused));
+		}
+	} else {
+		ast_copy_string(mem->reason_paused, "", sizeof(mem->reason_paused));
+	}
+
 	ast_devstate_changed(mem->paused ? QUEUE_PAUSED_DEVSTATE : QUEUE_UNPAUSED_DEVSTATE,
 		AST_DEVSTATE_CACHABLE, "Queue:%s_pause_%s", q->name, mem->interface);
 
@@ -9611,10 +9624,11 @@
 						"LastCall: %d\r\n"
 						"Status: %d\r\n"
 						"Paused: %d\r\n"
+						"PausedReason: %s\r\n"
 						"%s"
 						"\r\n",
 						q->name, mem->membername, mem->interface, mem->state_interface, mem->dynamic ? "dynamic" : "static",
-						mem->penalty, mem->calls, (int)mem->lastcall, mem->status, mem->paused, idText);
+						mem->penalty, mem->calls, (int)mem->lastcall, mem->status, mem->paused, mem->reason_paused, idText);
 					++q_items;
 				}
 				ao2_ref(mem, -1);
@@ -9768,7 +9782,7 @@
 	interface = astman_get_header(m, "Interface");
 	paused_s = astman_get_header(m, "Paused");
 	queuename = astman_get_header(m, "Queue");      /* Optional - if not supplied, pause the given Interface in all queues */
-	reason = astman_get_header(m, "Reason");        /* Optional - Only used for logging purposes */
+	reason = astman_get_header(m, "Reason");        /* Optional */
 
 	if (ast_strlen_zero(interface) || ast_strlen_zero(paused_s)) {
 		astman_send_error(s, m, "Need 'Interface' and 'Paused' parameters.");

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia5db503482f50764c15e2020196c785f59d4a68e
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Rodrigo Ramirez Norambuena <a at rodrigoramirez.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-code-review mailing list