Index: apps/app_queue.c =================================================================== --- apps/app_queue.c (revision 82304) +++ apps/app_queue.c (working copy) @@ -251,6 +251,9 @@ /*! \brief queues.conf [general] option */ static int montype_default = 0; +/*! \brief queues.conf [general] option */ +static int shared_lastcall = 0; + /*! \brief Subscription to device state change events */ static struct ast_event_sub *device_state_sub; @@ -291,6 +294,7 @@ int metric; int oldstatus; time_t lastcall; + struct call_queue *lastqueue; struct member *member; }; @@ -327,6 +331,7 @@ int status; /*!< Status of queue member */ int paused; /*!< Are we paused (not accepting calls)? */ time_t lastcall; /*!< When last successful call was hungup */ + struct call_queue *lastqueue; /*!< Last queue we received a call */ unsigned int dead:1; /*!< Used to detect members deleted in realtime */ unsigned int delme:1; /*!< Flag to delete entry on reload */ }; @@ -1805,8 +1810,10 @@ char *location; /* on entry here, we know that tmp->chan == NULL */ - if (qe->parent->wrapuptime && (time(NULL) - tmp->lastcall < qe->parent->wrapuptime)) { - ast_debug(1, "Wrapuptime not yet expired for %s\n", tmp->interface); + if ((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) ast_cdr_busy(qe->chan->cdr); tmp->stillgoing = 0; @@ -2437,9 +2444,35 @@ static int update_queue(struct call_queue *q, struct member *member, int callcompletedinsl) { + struct member *mem; + struct call_queue *qtmp; + struct ao2_iterator mem_iter; + + if (shared_lastcall) { + AST_LIST_LOCK(&queues); + AST_LIST_TRAVERSE(&queues, qtmp, list) { + ast_mutex_lock(&qtmp->lock); + mem_iter = ao2_iterator_init(qtmp->members, 0); + while ((mem = ao2_iterator_next(&mem_iter))) { + if (!strcasecmp(member->interface, mem->interface)) { + time(&mem->lastcall); + mem->calls++; + mem->lastqueue = q; + break; + } + ao2_ref(mem, -1); + } + ast_mutex_unlock(&qtmp->lock); + } + AST_LIST_UNLOCK(&queues); + } else { + ast_mutex_lock(&q->lock); + time(&member->lastcall); + member->calls++; + member->lastqueue = q; + ast_mutex_unlock(&q->lock); + } ast_mutex_lock(&q->lock); - time(&member->lastcall); - member->calls++; q->callscompleted++; if (callcompletedinsl) q->callscompletedinsl++; @@ -2637,6 +2670,7 @@ tmp->member = cur; tmp->oldstatus = cur->status; tmp->lastcall = cur->lastcall; + tmp->lastqueue = cur->lastqueue; ast_copy_string(tmp->interface, cur->interface, sizeof(tmp->interface)); /* Special case: If we ring everyone, go ahead and ring them, otherwise just calculate their metric for the appropriate strategy */ @@ -4100,6 +4134,9 @@ if ((general_val = ast_variable_retrieve(cfg, "general", "monitor-type"))) if (!strcasecmp(general_val, "mixmonitor")) montype_default = 1; + shared_lastcall = 0; + if ((general_val = ast_variable_retrieve(cfg, "general", "shared_lastcall"))) + shared_lastcall = ast_true(general_val); } else { /* Define queue */ /* Look for an existing one */ AST_LIST_TRAVERSE(&queues, q, list) { Index: configs/queues.conf.sample =================================================================== --- configs/queues.conf.sample (revision 82304) +++ configs/queues.conf.sample (working copy) @@ -51,7 +51,13 @@ ; an application call from extensions.conf: ; Queue(queuename|[options]|[optionalurl]|[announceoverride]|[timeout]) ; example: Queue(dave|t|||45) - +shared_lastcall = yes|no +; +; Make the lastcall and calls received be the same in members of more +; than one queue. +; This is usefull to make the queue respect the wrapuptime of another +; queue for a shared member. +; ;[markq] ; ; A sample call queue