Index: apps/app_queue.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_queue.c,v retrieving revision 1.40 diff -u -r1.40 app_queue.c --- apps/app_queue.c 19 Nov 2003 21:56:45 -0000 1.40 +++ apps/app_queue.c 28 Jan 2004 16:58:01 -0000 @@ -170,6 +170,9 @@ struct member *members; /* Member channels to be tried */ struct queue_ent *head; /* Start of the actual queue */ struct ast_call_queue *next; /* Next call queue */ + struct ast_call_queue *slave; /* a slave queue delivers no calls until we are empty */ + struct ast_call_queue *master; /* a master queue that has to be empty for this one to deliver calls */ + char master_name[80]; /* the name of the master queue used in the config */ }; static struct ast_call_queue *queues = NULL; @@ -284,6 +287,12 @@ } ast_mutex_unlock(&qlock); free_members(q, 1); + if (q->master) { + q->master->slave = NULL; + } + if (q->slave) { + q->slave->master = NULL; + } free(q); } @@ -711,6 +720,15 @@ int x=0; char *announce = NULL; char digit = 0; + ast_log(LOG_DEBUG, "Trying to get some answer from queue %s\n", qe->parent->name); + if (qe->parent->master) { + if (qe->parent->master->count) { + ast_log(LOG_DEBUG, "%s has a master with count = %d - this will have to wait\n", + qe->parent->name, + qe->parent->master->count); + return 0; + } + } /* Hold the lock while we setup the outgoing calls */ ast_mutex_lock(&qe->parent->lock); cur = qe->parent->members; @@ -1193,7 +1211,7 @@ static void reload_queues(void) { - struct ast_call_queue *q, *ql, *qn; + struct ast_call_queue *q, *ql, *qn, *q2; struct ast_config *cfg; char *cat, *tmp; struct ast_variable *var; @@ -1292,6 +1310,8 @@ q->timeout = atoi(var->value); } else if (!strcasecmp(var->name, "retry")) { q->retry = atoi(var->value); + } else if (!strcasecmp(var->name, "master")) { + strncpy(q->master_name, var->value, sizeof(q->master_name) - 1); } else if (!strcasecmp(var->name, "maxlen")) { q->maxlen = atoi(var->value); } else if (!strcasecmp(var->name, "strategy")) { @@ -1326,12 +1346,28 @@ ql = NULL; while(q) { qn = q->next; + if (q->master_name) { + q2 = queues; + while (q2) { + if (!strcmp(q->master_name, q2->name)) { + q->master = q2; + q2->slave = q; + } + q2 = q2->next; + } + } if (q->dead) { if (ql) ql->next = q->next; else queues = q->next; if (!q->count) { + if (q->master) { + q->master->slave = NULL; + } + if (q->slave) { + q->slave->master = NULL; + } free(q); } else ast_log(LOG_WARNING, "XXX Leaking a litttle memory :( XXX\n");