summaryrefslogtreecommitdiff
path: root/apps/app_queue.c
diff options
context:
space:
mode:
authorJason Parker <jparker@digium.com>2007-07-10 20:02:05 +0000
committerJason Parker <jparker@digium.com>2007-07-10 20:02:05 +0000
commit6f8294847fe339766a4106f288fa487bac5b3b20 (patch)
tree24176ed3067981e6b6141336e2853e814ea4dc38 /apps/app_queue.c
parent7c29e430c91fce45d6fe9df1749c2bd041e97f6c (diff)
Merged revisions 74428 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 (closes issue #10158) ................ r74428 | qwell | 2007-07-10 14:58:53 -0500 (Tue, 10 Jul 2007) | 14 lines Merged revisions 74427 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r74427 | qwell | 2007-07-10 14:57:20 -0500 (Tue, 10 Jul 2007) | 6 lines Fix an issue where it was possible to have a service level of over 100% Between the time recalc_holdtime and update_queue was called, it was possible that the call could have been hungup. Move both additions to the same place, so this won't happen. Issue 10158, initial patch by makoto, modified by me. ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@74429 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_queue.c')
-rw-r--r--apps/app_queue.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c
index f348dd4d7..21f91455c 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -1468,21 +1468,17 @@ playout:
return res;
}
-static void recalc_holdtime(struct queue_ent *qe)
+static void recalc_holdtime(struct queue_ent *qe, int newholdtime)
{
- int oldvalue, newvalue;
+ int oldvalue;
/* Calculate holdtime using a recursive boxcar filter */
/* Thanks to SRT for this contribution */
/* 2^2 (4) is the filter coefficient; a higher exponent would give old entries more weight */
- newvalue = time(NULL) - qe->start;
-
ast_mutex_lock(&qe->parent->lock);
- if (newvalue <= qe->parent->servicelevel)
- qe->parent->callscompletedinsl++;
oldvalue = qe->parent->holdtime;
- qe->parent->holdtime = (((oldvalue << 2) - oldvalue) + newvalue) >> 2;
+ qe->parent->holdtime = (((oldvalue << 2) - oldvalue) + newholdtime) >> 2;
ast_mutex_unlock(&qe->parent->lock);
}
@@ -2307,7 +2303,7 @@ static int wait_our_turn(struct queue_ent *qe, int ringing, enum queue_result *r
return res;
}
-static int update_queue(struct call_queue *q, struct member *member)
+static int update_queue(struct call_queue *q, struct member *member, int callcompletedinsl)
{
struct member *cur;
@@ -2324,6 +2320,8 @@ static int update_queue(struct call_queue *q, struct member *member)
cur = cur->next;
}
q->callscompleted++;
+ if (callcompletedinsl)
+ q->callscompletedinsl++;
ast_mutex_unlock(&q->lock);
return 0;
}
@@ -2450,6 +2448,8 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
char *p;
char vars[2048];
int forwardsallowed = 1;
+ int callcompletedinsl;
+
memset(&bridge_config, 0, sizeof(bridge_config));
time(&now);
@@ -2559,7 +2559,11 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
if (!strcmp(peer->tech->type, "Zap"))
ast_channel_setoption(peer, AST_OPTION_TONE_VERIFY, &nondataquality, sizeof(nondataquality), 0);
/* Update parameters for the queue */
- recalc_holdtime(qe);
+ time(&now);
+ recalc_holdtime(qe, (now - qe->start));
+ ast_mutex_lock(&qe->parent->lock);
+ callcompletedinsl = ((now - qe->start) <= qe->parent->servicelevel);
+ ast_mutex_unlock(&qe->parent->lock);
member = lpeer->member;
hangupcalls(outgoing, peer);
outgoing = NULL;
@@ -2893,7 +2897,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
if (bridge != AST_PBX_NO_HANGUP_PEER)
ast_hangup(peer);
- update_queue(qe->parent, member);
+ update_queue(qe->parent, member, callcompletedinsl);
res = bridge ? bridge : 1;
}
out: