]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
app_queue.c: Emit unpause reason with PauseQueueMember event.
authorSean Bright <sean@seanbright.com>
Mon, 30 Oct 2023 14:13:56 +0000 (10:13 -0400)
committerAsterisk Development Team <asteriskteam@digium.com>
Fri, 12 Jan 2024 18:32:13 +0000 (18:32 +0000)
Fixes #395

(cherry picked from commit baf3ce25f52337f987585cde7e7e93a9f05b7861)

apps/app_queue.c

index 4e4b2a8fc9f08603882dd6de932762c5409b3b95..b42a06681dd6b8237b710ad11e63df23c9de242e 100644 (file)
@@ -7798,6 +7798,9 @@ static void set_queue_member_pause(struct call_queue *q, struct member *mem, con
        if (paused && !ast_strlen_zero(reason)) {
                ast_copy_string(mem->reason_paused, reason, sizeof(mem->reason_paused));
        } else {
+               /* We end up filling this in again later (temporarily) but we need it
+                * empty for now so that the intervening code - specifically
+                * dump_queue_members() - has the correct view of things. */
                mem->reason_paused[0] = '\0';
        }
 
@@ -7816,10 +7819,22 @@ static void set_queue_member_pause(struct call_queue *q, struct member *mem, con
                        "Queue:%s_avail", q->name);
        }
 
-       ast_queue_log(q->name, "NONE", mem->membername, (paused ? "PAUSE" : "UNPAUSE"),
-               "%s", S_OR(reason, ""));
+       if (!paused && !ast_strlen_zero(reason)) {
+               /* Because we've been unpaused with a 'reason' we need to ensure that
+                * that reason is emitted when the subsequent PauseQueueMember event
+                * is raised. So temporarily set it on the member and clear it out
+                * again right after. */
+               ast_copy_string(mem->reason_paused, reason, sizeof(mem->reason_paused));
+       }
+
+       ast_queue_log(q->name, "NONE", mem->membername, paused ? "PAUSE" : "UNPAUSE",
+               "%s", mem->reason_paused);
 
        publish_queue_member_pause(q, mem);
+
+       if (!paused) {
+               mem->reason_paused[0] = '\0';
+       }
 }
 
 static int set_member_paused(const char *queuename, const char *interface, const char *reason, int paused)