[asterisk-commits] eliel: branch eliel/per_member_wrapuptime r188512 - /team/eliel/per_member_wr...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 15 09:44:28 CDT 2009
Author: eliel
Date: Wed Apr 15 09:44:24 2009
New Revision: 188512
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=188512
Log:
Make code more readable.
Modified:
team/eliel/per_member_wrapuptime/apps/app_queue.c
Modified: team/eliel/per_member_wrapuptime/apps/app_queue.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/per_member_wrapuptime/apps/app_queue.c?view=diff&rev=188512&r1=188511&r2=188512
==============================================================================
--- team/eliel/per_member_wrapuptime/apps/app_queue.c (original)
+++ team/eliel/per_member_wrapuptime/apps/app_queue.c Wed Apr 15 09:44:24 2009
@@ -2419,6 +2419,23 @@
return vars;
}
+/*!
+ * \brief Based on the lastcall and the configured wrapuptime,
+ * decide if the wrapuptime has expired.
+ * \param lastcall[in] The time the lastcall was received.
+ * \param wrapuptime[in] The configured wrapuptime.
+ * \retval 1 if the wrapuptime expired.
+ * \retval 0 if the wrapuptime didn't expired.
+ */
+static int wrapuptime_expired(int lastcall, int wrapuptime)
+{
+ if (time(NULL) - lastcall < wrapuptime) {
+ return 1;
+ }
+
+ return 0;
+}
+
/*!
* \brief Part 2 of ring_one
*
@@ -2436,19 +2453,43 @@
static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies)
{
int res;
- int status;
+ int status, wrapuptime_notexpired = 0;
char tech[256];
char *location;
const char *macrocontext, *macroexten;
+ struct member *mem;
+ struct call_queue *lastqueue;
/* on entry here, we know that tmp->chan == NULL */
- if ((tmp->member->current_wrapuptime >= 0 && (time(NULL) - tmp->lastcall < tmp->member->current_wrapuptime)) ||
- (tmp->lastqueue && tmp->lastqueue->wrapuptime && (time(NULL) - tmp->lastcall < tmp->lastqueue->wrapuptime)) ||
- (!tmp->lastqueue && qe->parent->wrapuptime && (time(NULL) - tmp->lastcall < qe->parent->wrapuptime))) {
- ast_debug(1, "Wrapuptime not yet expired on queue %s for %s\n",
- (tmp->lastqueue ? tmp->lastqueue->name : qe->parent->name), tmp->interface);
- if (qe->chan->cdr)
+
+ /* the member we are trying to call. */
+ mem = tmp->member;
+ /* lastqueue the member received a call from. */
+ lastqueue = tmp->lastqueue;
+
+ /* check if the wrapuptime expired so we are able to call this member. */
+ if (mem->current_wrapuptime >= 0 && wrapuptime_expired(tmp->lastcall, mem->current_wrapuptime)) {
+ /* the queue member has a wrapuptime configured and didn't expired yet. */
+ wrapuptime_notexpired = 1;
+ } else if (mem->current_wrapuptime < 0) {
+ /* the member doesn't have a specific wrapuptime configured. */
+ if (lastqueue && lastqueue->wrapuptime && wrapuptime_expired(tmp->lastcall, lastqueue->wrapuptime)) {
+ /* if the queue member doesn't have a wrapuptime configured, check for the wrapuptime of the last queue
+ * he received a call from. */
+ wrapuptime_notexpired = 1;
+ } else if (!lastqueue && qe->parent->wrapuptime && wrapuptime_expired(tmp->lastcall, qe->parent->wrapuptime)) {
+ /* If the member didn't received a call from another queue (or shared_lastcall is not enabled), check for the
+ * wrapuptime of the actual queue. */
+ wrapuptime_notexpired = 1;
+ }
+ }
+
+ if (wrapuptime_notexpired) {
+ ast_debug(1, "Wrapuptime not yet expired on queue %s for %s\n", (tmp->lastqueue ? tmp->lastqueue->name : qe->parent->name), tmp->interface);
+ ast_log(LOG_ERROR, "Wrapuptime not yet expired on queue %s for %s\n", (tmp->lastqueue ? tmp->lastqueue->name : qe->parent->name), tmp->interface);
+ if (qe->chan->cdr) {
ast_cdr_busy(qe->chan->cdr);
+ }
tmp->stillgoing = 0;
(*busies)++;
return 0;
More information about the asterisk-commits
mailing list