From d89ed4ab5f00f934676fc56179e3bfa9d3aa4f1c Mon Sep 17 00:00:00 2001
From: Mark Spencer <markster@digium.com>
Date: Sat, 24 Jul 2004 03:37:50 +0000
Subject: [PATCH] Create option for joining empty queue (bug #2126)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3502 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 apps/app_queue.c           | 5 ++++-
 configs/queues.conf.sample | 4 ++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/apps/app_queue.c b/apps/app_queue.c
index 6fe9f6d4a7..9acaa234e0 100755
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -216,6 +216,7 @@ struct ast_call_queue {
 	
 	int rrpos;			/* Round Robin - position */
 	int wrapped;			/* Round Robin - wrapped around? */
+	int joinempty;			/* Do we care if the queue has no members? */
 
 	struct member *members;		/* Member channels to be tried */
 	struct queue_ent *head;		/* Start of the actual queue */
@@ -280,7 +281,7 @@ static int join_queue(char *queuename, struct queue_ent *qe)
 		if (!strcasecmp(q->name, queuename)) {
 			/* This is our one */
 			ast_mutex_lock(&q->lock);
-			if (q->members && (!q->maxlen || (q->count < q->maxlen))) {
+			if ((q->members || q->joinempty) && (!q->maxlen || (q->count < q->maxlen))) {
 				/* There's space for us, put us at the right position inside
 				 * the queue. 
 				 * Take into account the priority of the calling user */
@@ -1830,6 +1831,8 @@ static void reload_queues(void)
 							ast_log(LOG_WARNING, "'%s' isn't a valid strategy, using ringall instead\n", var->value);
 							q->strategy = 0;
 						}
+					} else if (!strcasecmp(var->name, "joinempty")) {
+						q->joinempty = ast_true(var->value);
 					} else {
 						ast_log(LOG_WARNING, "Unknown keyword in queue '%s': %s at line %d of queue.conf\n", cat, var->name, var->lineno);
 					}
diff --git a/configs/queues.conf.sample b/configs/queues.conf.sample
index 66ed932420..ab331e1e87 100755
--- a/configs/queues.conf.sample
+++ b/configs/queues.conf.sample
@@ -107,6 +107,10 @@
 ;
 ; monitor-join = yes
 ;
+; If you wish to allow queues that have no members currently to be joined, set this to yes
+;
+; joinempty = yes
+;
 ; Each member of this call queue is listed on a separate line in
 ; the form technology/dialstring.  "member" means a normal member of a
 ; queue.  An optional penalty may be specified after a comma, such that
-- 
GitLab