[asterisk-commits] qwell: branch 1.4 r74428 - in /branches/1.4: ./ apps/app_queue.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 10 14:58:54 CDT 2007


Author: qwell
Date: Tue Jul 10 14:58:53 2007
New Revision: 74428

URL: http://svn.digium.com/view/asterisk?view=rev&rev=74428
Log:
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.

........

Modified:
    branches/1.4/   (props changed)
    branches/1.4/apps/app_queue.c

Propchange: branches/1.4/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Modified: branches/1.4/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_queue.c?view=diff&rev=74428&r1=74427&r2=74428
==============================================================================
--- branches/1.4/apps/app_queue.c (original)
+++ branches/1.4/apps/app_queue.c Tue Jul 10 14:58:53 2007
@@ -1376,21 +1376,17 @@
 	return res;
 }
 
-static void recalc_holdtime(struct queue_ent *qe)
-{
-	int oldvalue, newvalue;
+static void recalc_holdtime(struct queue_ent *qe, int newholdtime)
+{
+	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);
 }
 
@@ -2219,7 +2215,7 @@
 	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;
 
@@ -2236,6 +2232,8 @@
 		cur = cur->next;
 	}
 	q->callscompleted++;
+	if (callcompletedinsl)
+		q->callscompletedinsl++;
 	ast_mutex_unlock(&q->lock);
 	return 0;
 }
@@ -2329,6 +2327,7 @@
 	char *p;
 	char vars[2048];
 	int forwardsallowed = 1;
+	int callcompletedinsl;
 
 	memset(&bridge_config, 0, sizeof(bridge_config));
 	time(&now);
@@ -2441,7 +2440,11 @@
 		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;
@@ -2688,7 +2691,7 @@
 
 		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:




More information about the asterisk-commits mailing list