--- asterisk-1.4-last/apps/app_queue.c 2008-03-26 17:29:08.000000000 -0300 +++ asterisk-1.4/apps/app_queue.c 2008-03-27 16:25:29.000000000 -0300 @@ -263,6 +263,9 @@ /*! \brief queues.conf [general] option */ static int queue_persistent_members = 0; +/*! \brief queues.conf [general] option */ +static int global_wrapuptime = 0; + /*! \brief queues.conf per-queue weight option */ static int use_weight = 0; @@ -2459,15 +2462,42 @@ return res; } +/*! \brief Update lastcall time of member in all queues it belongs + * + * We iterate through all the queues and update the lastcall time of every member + * that shares the same interface with the agent that just ended the call. + * This makes wrapuptime work through different queues with "shared" members. + */ +static void update_member_lastcall(struct member *member){ + struct call_queue *q; + struct member *cur; + struct ao2_iterator mem_iter; + + AST_LIST_LOCK(&queues); + AST_LIST_TRAVERSE(&queues, q, list) { + ast_mutex_lock(&q->lock); + mem_iter = ao2_iterator_init(q->members, 0); + while ((cur = ao2_iterator_next(&mem_iter))) { + if ( member && ( strcasecmp(cur->interface, member->interface) == 0 ) ) + time(&cur->lastcall); + } + ast_mutex_unlock(&q->lock); + } + AST_LIST_UNLOCK(&queues); +} + static int update_queue(struct call_queue *q, struct member *member, int callcompletedinsl) { ast_mutex_lock(&q->lock); - time(&member->lastcall); + if (! global_wrapuptime) + time(&member->lastcall); member->calls++; q->callscompleted++; if (callcompletedinsl) q->callscompletedinsl++; ast_mutex_unlock(&q->lock); + if (global_wrapuptime) + update_member_lastcall(member); return 0; } @@ -4139,6 +4169,9 @@ queue_persistent_members = 0; if ((general_val = ast_variable_retrieve(cfg, "general", "persistentmembers"))) queue_persistent_members = ast_true(general_val); + global_wrapuptime = 0; + if ((general_val = ast_variable_retrieve(cfg, "general", "global_wrapuptime"))) + global_wrapuptime = ast_true(general_val); autofill_default = 0; if ((general_val = ast_variable_retrieve(cfg, "general", "autofill"))) autofill_default = ast_true(general_val);