app_queue: Fix initial hold time queue statistic
authorSungtae Kim <pchero21@gmail.com>
Thu, 17 Aug 2017 21:46:49 +0000 (23:46 +0200)
committerJoshua Colp <jcolp@digium.com>
Tue, 22 Aug 2017 12:36:25 +0000 (07:36 -0500)
Fixed to use correct initial value and fixed to use the
correct queue info to check the first value.

ASTERISK-27204

Change-Id: Ia9e36c828e566e1cc25c66f73307566e4acb8e73

apps/app_queue.c

index 004d93a..b139ef7 100644 (file)
@@ -4072,8 +4072,12 @@ static void recalc_holdtime(struct queue_ent *qe, int newholdtime)
        /* 2^2 (4) is the filter coefficient; a higher exponent would give old entries more weight */
 
        ao2_lock(qe->parent);
-       oldvalue = qe->parent->holdtime;
-       qe->parent->holdtime = (((oldvalue << 2) - oldvalue) + newholdtime) >> 2;
+       if ((qe->parent->callscompleted + qe->parent->callsabandoned) == 0) {
+               qe->parent->holdtime = newholdtime;
+       } else {
+               oldvalue = qe->parent->holdtime;
+               qe->parent->holdtime = (((oldvalue << 2) - oldvalue) + newholdtime) >> 2;
+       }
        ao2_unlock(qe->parent);
 }
 
@@ -5651,7 +5655,7 @@ static int update_queue(struct call_queue *q, struct member *member, int callcom
        if (callcompletedinsl) {
                q->callscompletedinsl++;
        }
-       if (q->callscompletedinsl == 1) {
+       if (q->callscompleted == 1) {
                q->talktime = newtalktime;
        } else {
                /* Calculate talktime using the same exponential average as holdtime code */