I've just backported it to asterisk 1.4.19,
the patch is atached
2008/8/27 Bob Pierce <[email protected]>
>
> On Wed, 2008-08-27 at 11:21 +0300, Atis Lezdins wrote:
> > If you doubt about some part, you're welcome to ask, i'll try to help
> > you, but i don't want to provide complete backport to you, as i won't
> > be able to test it :)
>
> Thanks Atis,
>
> I'll probably try this in a few weeks when I start rebuilding the
> permanent system that will replace our current temporary system.
> That should give us the opportunity to test it on the bench instead of
> playing around with the production box.
>
> I'll probably be back to ask for help.
>
> Have a great day,
> Bob
>
> _______________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> AstriCon 2008 - September 22 - 25 Phoenix, Arizona
> Register Now: http://www.astricon.net
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-users
>
--- app_queue-orig.c 2009-04-07 15:10:12.256746320 -0300
+++ app_queue.c 2009-04-07 15:14:54.602271840 -0300
@@ -272,6 +272,9 @@
/*! \brief queues.conf [general] option */
static int montype_default = 0;
+/*! \brief queues.conf [general] option */
+static int shared_lastcall = 0;
+
enum queue_result {
QUEUE_UNKNOWN = 0,
QUEUE_TIMEOUT = 1,
@@ -315,6 +318,7 @@
int metric;
int oldstatus;
time_t lastcall;
+ struct call_queue *lastqueue;
struct member *member;
};
@@ -352,6 +356,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 */
};
@@ -795,7 +800,7 @@
static int member_cmp_fn(void *obj1, void *obj2, int flags)
{
struct member *mem1 = obj1, *mem2 = obj2;
- return strcmp(mem1->interface, mem2->interface) ? 0 : CMP_MATCH;
+ return strcasecmp(mem1->interface, mem2->interface) ? 0 : CMP_MATCH;
}
static void init_queue(struct call_queue *q)
@@ -1783,9 +1788,10 @@
char *location;
/* on entry here, we know that tmp->chan == NULL */
- if (qe->parent->wrapuptime && (time(NULL) - tmp->lastcall < qe->parent->wrapuptime)) {
+ 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))) {
if (option_debug)
- ast_log(LOG_DEBUG, "Wrapuptime not yet expired for %s\n", tmp->interface);
+ ast_log(LOG_DEBUG, "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;
@@ -2461,12 +2467,33 @@
static int update_queue(struct call_queue *q, struct member *member, int callcompletedinsl)
{
+ struct member *mem;
+ struct call_queue *qtmp;
+
+ if (shared_lastcall) {
+ AST_LIST_LOCK(&queues);
+ AST_LIST_TRAVERSE(&queues, qtmp, list) {
+ ast_mutex_lock(&qtmp->lock);
+ if ((mem = ao2_find(qtmp->members, member, OBJ_POINTER))) {
+ time(&mem->lastcall);
+ mem->calls++;
+ mem->lastqueue = q;
+ ao2_ref(mem, -1);
+ }
+ ast_mutex_unlock(&qtmp->lock);
+ }
+ AST_LIST_UNLOCK(&queues);
+ }
+
ast_mutex_lock(&q->lock);
- time(&member->lastcall);
- member->calls++;
q->callscompleted++;
if (callcompletedinsl)
q->callscompletedinsl++;
+ if (!shared_lastcall) {
+ time(&member->lastcall);
+ member->calls++;
+ member->lastqueue = q;
+ }
ast_mutex_unlock(&q->lock);
return 0;
}
@@ -2726,6 +2753,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 */
@@ -2870,7 +2898,7 @@
pbx_builtin_setvar_helper(qe->chan, "MEMBERINTERFACE", member->interface);
/* Begin Monitoring */
- if (qe->parent->monfmt && *qe->parent->monfmt) {
+ if (qe->parent->monfmt && strlen(qe->parent->monfmt) > 2) {
if (!qe->parent->montype) {
if (option_debug)
ast_log(LOG_DEBUG, "Starting Monitor as requested.\n");
@@ -4146,6 +4174,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) {
_______________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users