summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2012-08-15 23:35:35 +0000
committerMark Michelson <mmichelson@digium.com>2012-08-15 23:35:35 +0000
commitf4a34ee89ce3c1e2e1b92ff2ebf9d79bc517e57b (patch)
tree6f71df1ecc870c8c3b4f789e15246e5f2a4125b6 /apps
parent7aac43b4b18a5154f53561fbef959246397d1364 (diff)
Fix bug where final queue member would not be removed from memory.
If a static queue had realtime members, then there could be a potential for those realtime members not to be properly deleted from memory. If the queue's members were loaded from realtime and then all the members were deleted from the backend, then the queue would still think these members existed. The reason was that there was a short- circuit in code such that if there were no members found in the backend, then the queue would not be updated to reflect this. Note that this only affected static queues with realtime members. Realtime queues with realtime members were unaffected by this issue. (closes issue ASTERISK-19793) reported by Marcus Haas ........ Merged revisions 371306 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 371313 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 371324 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@371325 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r--apps/app_queue.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 38401607b..6265308b7 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -2687,8 +2687,19 @@ static void update_realtime_members(struct call_queue *q)
struct ao2_iterator mem_iter;
if (!(member_config = ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", q->name , SENTINEL))) {
- /*This queue doesn't have realtime members*/
+ /* This queue doesn't have realtime members. If the queue still has any realtime
+ * members in memory, they need to be removed.
+ */
+ ao2_lock(q);
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((m = ao2_iterator_next(&mem_iter))) {
+ if (m->realtime) {
+ ao2_unlink(q->members, m);
+ }
+ ao2_ref(m, -1);
+ }
ast_debug(3, "Queue %s has no realtime members defined. No need for update\n", q->name);
+ ao2_unlock(q);
return;
}