]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
app_queue: Only remove queue member from pending when state changes. 04/3204/1
authorJoshua Colp <jcolp@digium.com>
Thu, 14 Jul 2016 12:45:10 +0000 (09:45 -0300)
committerJoshua Colp <jcolp@digium.com>
Thu, 14 Jul 2016 12:45:10 +0000 (09:45 -0300)
It is possible for a not in use state change to occur multiple
times causing a queue member to be removed from the pending call
container prematurely.

The first not in use state change will remove the queue member
from the container. At this moment the member may be called and
placed in the pending container. After this another not in use
state change can be received which will remove it from the
container. Despite being called at this point the code will
incorrectly see that there are no pending calls to it.

This change only removes it from the pending container if the
state has actually changed.

ASTERISK-26133 #close
patches:
  app_queue.diff submitted by Richard Miller (license 5685)

Change-Id: Ie5a7f17a44f98e9159e9b85009ce3f8393aa78c0

apps/app_queue.c

index c3b735006a9f5f4b5d9b213051698e2aafef6b85..6ad65a2c40fcc0403ebd0037bd284fcdd2d13ad0 100644 (file)
@@ -1719,10 +1719,17 @@ struct statechange {
 */
 static int update_status(struct call_queue *q, struct member *m, const int status)
 {
-       m->status = status;
-
-       /* Whatever the status is clear the member from the pending members pool */
-       pending_members_remove(m);
+       if (m->status != status) {
+               m->status = status;
+
+               /* Remove the member from the pending members pool only when the status changes.
+                * This is not done unconditionally because we can occasionally see multiple
+                * device state notifications of not in use after a previous call has ended,
+                * including after we have initiated a new call. This is more likely to
+                * happen when there is latency in the connection to the member.
+                */
+               pending_members_remove(m);
+       }
 
        if (q->maskmemberstatus) {
                return 0;