[Asterisk-code-review] app_queue: periodic-announce-startdelay option. (asterisk[master])

Jaco Kroon asteriskteam at digium.com
Wed Apr 12 05:47:02 CDT 2023


Jaco Kroon has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/20080 )


Change subject: app_queue: periodic-announce-startdelay option.
......................................................................

app_queue: periodic-announce-startdelay option.

This newly introduced periodic-announce-startdelay makes it possible to
configure the initial start delay of the first periodic announcement
after which periodic-announce-frequency takes over.

The original patch introduced a null dereference due to incorrect
ordering.  This one fixes that (as shown by testing on
https://gerrit.asterisk.org/c/asterisk/+/20039)

ASTERISK-30492 #close
ASTERISK-30437 #close
Signed-off-by: Jaco Kroon <jaco at uls.co.za>

Change-Id: If2be8d04976a3b7204e777c5d80a78c2c11ecd24
---
M apps/app_queue.c
M configs/samples/queues.conf.sample
A doc/CHANGES-staging/app_queue.txt
3 files changed, 46 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/80/20080/1

diff --git a/apps/app_queue.c b/apps/app_queue.c
index 9eebb2f..1ab5bd1 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -1836,6 +1836,7 @@
 	int announcepositionlimit;          /*!< How many positions we announce? */
 	int announcefrequency;              /*!< How often to announce their position */
 	int minannouncefrequency;           /*!< The minimum number of seconds between position announcements (def. 15) */
+	int periodicannouncestartdelay;     /*!< How long into the queue should the periodic accouncement start */
 	int periodicannouncefrequency;      /*!< How often to play periodic announcement */
 	int numperiodicannounce;            /*!< The number of periodic announcements configured */
 	int randomperiodicannounce;         /*!< Are periodic announcments randomly chosen */
@@ -2964,6 +2965,7 @@
 	q->weight = 0;
 	q->timeoutrestart = 0;
 	q->periodicannouncefrequency = 0;
+	q->periodicannouncestartdelay = -1;
 	q->randomperiodicannounce = 0;
 	q->numperiodicannounce = 0;
 	q->relativeperiodicannounce = 0;
@@ -3420,6 +3422,8 @@
 			ast_str_set(&q->sound_periodicannounce[0], 0, "%s", val);
 			q->numperiodicannounce = 1;
 		}
+	} else if (!strcasecmp(param, "periodic-announce-startdelay")) {
+		q->periodicannouncestartdelay = atoi(val);
 	} else if (!strcasecmp(param, "periodic-announce-frequency")) {
 		q->periodicannouncefrequency = atoi(val);
 	} else if (!strcasecmp(param, "relative-periodic-announce")) {
@@ -8528,6 +8532,11 @@
 	}
 	ast_assert(qe.parent != NULL);
 
+	if (qe.parent->periodicannouncestartdelay >= 0) {
+		qe.last_periodic_announce_time += qe.parent->periodicannouncestartdelay;
+		qe.last_periodic_announce_time -= qe.parent->periodicannouncefrequency;
+	}
+
 	ast_queue_log(args.queuename, ast_channel_uniqueid(chan), "NONE", "ENTERQUEUE", "%s|%s|%d",
 		S_OR(args.url, ""),
 		S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, ""),
diff --git a/configs/samples/queues.conf.sample b/configs/samples/queues.conf.sample
index 0987236..7b5fe0b 100644
--- a/configs/samples/queues.conf.sample
+++ b/configs/samples/queues.conf.sample
@@ -278,6 +278,13 @@
 ;
 ;periodic-announce-frequency=60
 ;
+; If given indicates the number of seconds after entering the queue the first
+; periodic announcement should be played.  The default (and historic) behavior
+; is to play the first periodic announcement at periodic-announce-frequency
+; seconds after entering the queue.
+;
+;periodic-announce-startdelay=10
+;
 ; Should the periodic announcements be played in a random order? Default is no.
 ;
 ;random-periodic-announce=no
diff --git a/doc/CHANGES-staging/app_queue.txt b/doc/CHANGES-staging/app_queue.txt
new file mode 100644
index 0000000..f71bcb0
--- /dev/null
+++ b/doc/CHANGES-staging/app_queue.txt
@@ -0,0 +1,9 @@
+Subject: app_queue
+
+Introduce a new queue configuration option called
+'periodic-announce-startdelay' which will vary the normal (historic) behavior
+of starting the periodic announcement cycle at periodic-announce-frequency
+seconds after entering the queue to start the periodic announcement cycle at
+period-announce-startdelay seconds after joining the queue.
+
+The default behavior if this config option is not set remains unchanged.

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/20080
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: If2be8d04976a3b7204e777c5d80a78c2c11ecd24
Gerrit-Change-Number: 20080
Gerrit-PatchSet: 1
Gerrit-Owner: Jaco Kroon <jaco at uls.co.za>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230412/c1130461/attachment.html>


More information about the asterisk-code-review mailing list