diff -urN asterisk-1.4.6.orig/apps/app_queue.c asterisk-1.4.6/apps/app_queue.c --- asterisk-1.4.6.orig/apps/app_queue.c 2007-06-28 07:45:49.000000000 +0900 +++ asterisk-1.4.6/apps/app_queue.c 2007-07-06 15:42:02.976023600 +0900 @@ -1376,7 +1376,7 @@ return res; } -static void recalc_holdtime(struct queue_ent *qe) +static int recalc_holdtime(struct queue_ent *qe) { int oldvalue, newvalue; @@ -1387,11 +1387,11 @@ 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; ast_mutex_unlock(&qe->parent->lock); + + return newvalue; } @@ -2219,7 +2219,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 +2236,8 @@ cur = cur->next; } q->callscompleted++; + if (callcompletedinsl) + q->callscompletedinsl++; ast_mutex_unlock(&q->lock); return 0; } @@ -2330,6 +2332,8 @@ char vars[2048]; int forwardsallowed = 1; + int callcompletedinsl; + memset(&bridge_config, 0, sizeof(bridge_config)); time(&now); @@ -2442,7 +2446,7 @@ 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); + callcompletedinsl = (recalc_holdtime(qe) <= qe->parent->servicelevel); member = lpeer->member; hangupcalls(outgoing, peer); outgoing = NULL; @@ -2689,7 +2693,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: