Index: apps/app_queue.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_queue.c,v retrieving revision 1.129 diff -u -r1.129 app_queue.c --- apps/app_queue.c 28 Mar 2005 20:48:24 -0000 1.129 +++ apps/app_queue.c 31 Mar 2005 08:58:21 -0000 @@ -276,7 +276,7 @@ unsigned int timeoutrestart:1; unsigned int announceholdtime:2; unsigned int strategy:3; - }; + } flags; int announcefrequency; /* How often to announce their position */ int roundingseconds; /* How many seconds do we round to? */ int holdtime; /* Current avg holdtime, based on recursive boxcar filter */ @@ -487,9 +487,9 @@ /* This is our one */ ast_mutex_lock(&q->lock); stat = get_member_status(q); - if (!q->joinempty && (stat == QUEUE_NO_MEMBERS)) + if (!q->flags.joinempty && (stat == QUEUE_NO_MEMBERS)) *reason = QUEUE_JOINEMPTY; - else if ((q->joinempty == QUEUE_EMPTY_NORMAL) && (stat == QUEUE_NO_REACHABLE_MEMBERS)) + else if ((q->flags.joinempty == QUEUE_EMPTY_NORMAL) && (stat == QUEUE_NO_REACHABLE_MEMBERS)) *reason = QUEUE_JOINUNAVAIL; else if (q->maxlen && (q->count >= q->maxlen)) *reason = QUEUE_FULL; @@ -641,8 +641,8 @@ /* If the hold time is >1 min, if it's enabled, and if it's not supposed to be only once and we have already said it, say it */ - if ((avgholdmins+avgholdsecs) > 0 && (qe->parent->announceholdtime) && - (!(qe->parent->announceholdtime == ANNOUNCEHOLDTIME_ONCE) && qe->last_pos)) { + if ((avgholdmins+avgholdsecs) > 0 && (qe->parent->flags.announceholdtime) && + (!(qe->parent->flags.announceholdtime == ANNOUNCEHOLDTIME_ONCE) && qe->last_pos)) { res += play_file(qe->chan, qe->parent->sound_holdtime); if(avgholdmins>0) { if (avgholdmins < 2) { @@ -735,7 +735,7 @@ cur = cur->next; } ast_mutex_unlock(&q->lock); - if (q->dead && !q->count) { + if (q->flags.dead && !q->count) { /* It's dead and nobody is in it, so kill it */ destroy_queue(q); } @@ -928,7 +928,7 @@ (*busies)++; return 0; } else { - if (qe->parent->eventwhencalled) { + if (qe->parent->flags.eventwhencalled) { manager_event(EVENT_FLAG_AGENT, "AgentCalled", "AgentCalled: %s\r\n" "ChannelCalling: %s\r\n" @@ -967,7 +967,7 @@ cur = cur->next; } if (best) { - if (!qe->parent->strategy) { + if (!qe->parent->flags.strategy) { /* Ring everyone who shares this best metric (for ringall) */ cur = outgoing; while(cur) { @@ -1018,7 +1018,7 @@ qe->parent->rrpos = best->metric % 1000; } else { /* Just increment rrpos */ - if (qe->parent->wrapped) { + if (qe->parent->flags.wrapped) { /* No more channels, start over */ qe->parent->rrpos = 0; } else { @@ -1026,7 +1026,7 @@ qe->parent->rrpos++; } } - qe->parent->wrapped = 0; + qe->parent->flags.wrapped = 0; return 0; } @@ -1090,7 +1090,7 @@ while(*to && !peer) { BUILD_WATCHERS; - if ((found < 0) && stillgoing && !qe->parent->strategy) { + if ((found < 0) && stillgoing && !qe->parent->flags.strategy) { /* On "ringall" strategy we only move to the next penalty level when *all* ringing phones are done in the current penalty level */ ring_one(qe, outgoing, &numbusies); @@ -1208,8 +1208,8 @@ ast_cdr_busy(in->cdr); ast_hangup(o->chan); o->chan = NULL; - if (qe->parent->strategy) { - if (qe->parent->timeoutrestart) + if (qe->parent->flags.strategy) { + if (qe->parent->flags.timeoutrestart) *to = orig; ring_one(qe, outgoing, &numbusies); } @@ -1223,8 +1223,8 @@ ast_cdr_busy(in->cdr); ast_hangup(o->chan); o->chan = NULL; - if (qe->parent->strategy) { - if (qe->parent->timeoutrestart) + if (qe->parent->flags.strategy) { + if (qe->parent->flags.timeoutrestart) *to = orig; ring_one(qe, outgoing, &numbusies); } @@ -1252,8 +1252,8 @@ o->stillgoing = 0; ast_hangup(o->chan); o->chan = NULL; - if (qe->parent->strategy) { - if (qe->parent->timeoutrestart) + if (qe->parent->flags.strategy) { + if (qe->parent->flags.timeoutrestart) *to = orig; ring_one(qe, outgoing, &numbusies); } @@ -1336,14 +1336,14 @@ stat = get_member_status(qe->parent); /* leave the queue if no agents, if enabled */ - if (qe->parent->leavewhenempty && (stat == QUEUE_NO_MEMBERS)) { + if (qe->parent->flags.leavewhenempty && (stat == QUEUE_NO_MEMBERS)) { *reason = QUEUE_LEAVEEMPTY; leave_queue(qe); break; } /* leave the queue if no reachable agents, if enabled */ - if ((qe->parent->leavewhenempty == QUEUE_EMPTY_NORMAL) && (stat == QUEUE_NO_REACHABLE_MEMBERS)) { + if ((qe->parent->flags.leavewhenempty == QUEUE_EMPTY_NORMAL) && (stat == QUEUE_NO_REACHABLE_MEMBERS)) { *reason = QUEUE_LEAVEUNAVAIL; leave_queue(qe); break; @@ -1384,21 +1384,21 @@ static int calc_metric(struct ast_call_queue *q, struct member *mem, int pos, struct queue_ent *qe, struct localuser *tmp) { - switch (q->strategy) { + switch (q->flags.strategy) { case QUEUE_STRATEGY_RINGALL: /* Everyone equal, except for penalty */ tmp->metric = mem->penalty * 1000000; break; case QUEUE_STRATEGY_ROUNDROBIN: if (!pos) { - if (!q->wrapped) { + if (!q->flags.wrapped) { /* No more channels, start over */ q->rrpos = 0; } else { /* Prioritize next entry */ q->rrpos++; } - q->wrapped = 0; + q->flags.wrapped = 0; } /* Fall through */ case QUEUE_STRATEGY_RRMEMORY: @@ -1407,7 +1407,7 @@ } else { if (pos > q->rrpos) /* Indicate there is another priority */ - q->wrapped = 1; + q->flags.wrapped = 1; tmp->metric = pos; } tmp->metric += mem->penalty * 1000000; @@ -1428,7 +1428,7 @@ tmp->metric += mem->penalty * 1000000; break; default: - ast_log(LOG_WARNING, "Can't calculate metric for unknown strategy %d\n", q->strategy); + ast_log(LOG_WARNING, "Can't calculate metric for unknown strategy %d\n", q->flags.strategy); break; } return 0; @@ -1553,7 +1553,7 @@ ast_mutex_unlock(&qlock); lpeer = wait_for_answer(qe, outgoing, &to, &digit, numbusies, ast_test_flag(&(bridge_config.features_caller), AST_FEATURE_DISCONNECT)); ast_mutex_lock(&qe->parent->lock); - if (qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY) { + if (qe->parent->flags.strategy == QUEUE_STRATEGY_RRMEMORY) { store_next(qe, outgoing); } ast_mutex_unlock(&qe->parent->lock); @@ -1591,7 +1591,7 @@ member = lpeer->member; hangupcalls(outgoing, peer); outgoing = NULL; - if (announce || qe->parent->reportholdtime || qe->parent->memberdelay) { + if (announce || qe->parent->flags.reportholdtime || qe->parent->memberdelay) { int res2; res2 = ast_autoservice_start(qe->chan); if (!res2) { @@ -1603,7 +1603,7 @@ if (play_file(peer, announce)) ast_log(LOG_WARNING, "Announcement file '%s' is unavailable, continuing anyway...\n", announce); } - if (!res2 && qe->parent->reportholdtime) { + if (!res2 && qe->parent->flags.reportholdtime) { if (!play_file(peer, qe->parent->sound_reporthold)) { int holdtime; time_t now; @@ -1624,7 +1624,7 @@ /* Agent must have hung up */ ast_log(LOG_WARNING, "Agent on %s hungup on the customer. They're going to be pissed.\n", peer->name); ast_queue_log(queuename, qe->chan->uniqueid, peer->name, "AGENTDUMP", "%s", ""); - if (qe->parent->eventwhencalled) { + if (qe->parent->flags.eventwhencalled) { manager_event(EVENT_FLAG_AGENT, "AgentDump", "Queue: %s\r\n" "Uniqueid: %s\r\n" @@ -1667,7 +1667,7 @@ ast_monitor_start(which, qe->parent->monfmt, monitorfilename, 1 ); else ast_monitor_start(which, qe->parent->monfmt, qe->chan->cdr->uniqueid, 1 ); - if (qe->parent->monjoin) + if (qe->parent->flags.monjoin) ast_monitor_setjoinfiles(which, 1); } /* Drop out of the queue at this point, to prepare for next caller */ @@ -1678,7 +1678,7 @@ ast_channel_sendurl(peer, url); } ast_queue_log(queuename, qe->chan->uniqueid, peer->name, "CONNECT", "%ld", (long)time(NULL) - qe->start); - if (qe->parent->eventwhencalled) + if (qe->parent->flags.eventwhencalled) manager_event(EVENT_FLAG_AGENT, "AgentConnect", "Queue: %s\r\n" "Uniqueid: %s\r\n" @@ -1698,7 +1698,7 @@ } else if (qe->chan->_softhangup) { ast_queue_log(queuename, qe->chan->uniqueid, peer->name, "COMPLETECALLER", "%ld|%ld", (long)(callstart - qe->start), (long)(time(NULL) - callstart)); - if (qe->parent->eventwhencalled) + if (qe->parent->flags.eventwhencalled) manager_event(EVENT_FLAG_AGENT, "AgentComplete", "Queue: %s\r\n" "Uniqueid: %s\r\n" @@ -1711,7 +1711,7 @@ (long)(callstart - qe->start), (long)(time(NULL) - callstart)); } else { ast_queue_log(queuename, qe->chan->uniqueid, peer->name, "COMPLETEAGENT", "%ld|%ld", (long)(callstart - qe->start), (long)(time(NULL) - callstart)); - if (qe->parent->eventwhencalled) + if (qe->parent->flags.eventwhencalled) manager_event(EVENT_FLAG_AGENT, "AgentComplete", "Queue: %s\r\n" "Uniqueid: %s\r\n" @@ -2411,14 +2411,14 @@ stat = get_member_status(qe.parent); /* leave the queue if no agents, if enabled */ - if (qe.parent->leavewhenempty && (stat == QUEUE_NO_MEMBERS)) { + if (qe.parent->flags.leavewhenempty && (stat == QUEUE_NO_MEMBERS)) { reason = QUEUE_LEAVEEMPTY; res = 0; break; } /* leave the queue if no reachable agents, if enabled */ - if ((qe.parent->leavewhenempty == QUEUE_EMPTY_NORMAL) && (stat == QUEUE_NO_REACHABLE_MEMBERS)) { + if ((qe.parent->flags.leavewhenempty == QUEUE_EMPTY_NORMAL) && (stat == QUEUE_NO_REACHABLE_MEMBERS)) { reason = QUEUE_LEAVEUNAVAIL; res = 0; break; @@ -2510,7 +2510,7 @@ /* Mark all queues as dead for the moment */ q = queues; while(q) { - q->dead = 1; + q->flags.dead = 1; q = q->next; } /* Chug through config file */ @@ -2540,12 +2540,12 @@ if (!new) ast_mutex_lock(&q->lock); /* Re-initialize the queue */ - q->dead = 0; + q->flags.dead = 0; q->retry = DEFAULT_RETRY; q->timeout = -1; q->maxlen = 0; q->announcefrequency = 0; - q->announceholdtime = 0; + q->flags.announceholdtime = 0; q->roundingseconds = 0; /* Default - don't announce seconds */ q->holdtime = 0; q->callscompleted = 0; @@ -2605,7 +2605,7 @@ } else if (!strcasecmp(var->name, "timeout")) { q->timeout = atoi(var->value); } else if (!strcasecmp(var->name, "monitor-join")) { - q->monjoin = ast_true(var->value); + q->flags.monjoin = ast_true(var->value); } else if (!strcasecmp(var->name, "monitor-format")) { strncpy(q->monfmt, var->value, sizeof(q->monfmt) - 1); } else if (!strcasecmp(var->name, "queue-youarenext")) { @@ -2636,11 +2636,11 @@ } } else if (!strcasecmp(var->name, "announce-holdtime")) { if (!strcasecmp(var->value, "once")) - q->announceholdtime = ANNOUNCEHOLDTIME_ONCE; + q->flags.announceholdtime = ANNOUNCEHOLDTIME_ONCE; else if (ast_true(var->value)) - q->announceholdtime = ANNOUNCEHOLDTIME_ALWAYS; + q->flags.announceholdtime = ANNOUNCEHOLDTIME_ALWAYS; else - q->announceholdtime = 0; + q->flags.announceholdtime = 0; } else if (!strcasecmp(var->name, "retry")) { q->retry = atoi(var->value); } else if (!strcasecmp(var->name, "wrapuptime")) { @@ -2650,29 +2650,29 @@ } else if (!strcasecmp(var->name, "servicelevel")) { q->servicelevel= atoi(var->value); } else if (!strcasecmp(var->name, "strategy")) { - q->strategy = strat2int(var->value); - if (q->strategy < 0) { + q->flags.strategy = strat2int(var->value); + if (q->flags.strategy < 0) { ast_log(LOG_WARNING, "'%s' isn't a valid strategy, using ringall instead\n", var->value); - q->strategy = 0; + q->flags.strategy = 0; } } else if (!strcasecmp(var->name, "joinempty")) { if (!strcasecmp(var->value, "strict")) - q->joinempty = QUEUE_EMPTY_STRICT; + q->flags.joinempty = QUEUE_EMPTY_STRICT; else if (ast_true(var->value)) - q->joinempty = QUEUE_EMPTY_NORMAL; + q->flags.joinempty = QUEUE_EMPTY_NORMAL; else - q->joinempty = 0; + q->flags.joinempty = 0; } else if (!strcasecmp(var->name, "leavewhenempty")) { if (!strcasecmp(var->value, "strict")) - q->leavewhenempty = QUEUE_EMPTY_STRICT; + q->flags.leavewhenempty = QUEUE_EMPTY_STRICT; else if (ast_true(var->value)) - q->leavewhenempty = QUEUE_EMPTY_NORMAL; + q->flags.leavewhenempty = QUEUE_EMPTY_NORMAL; else - q->leavewhenempty = 0; + q->flags.leavewhenempty = 0; } else if (!strcasecmp(var->name, "eventwhencalled")) { - q->eventwhencalled = ast_true(var->value); + q->flags.eventwhencalled = ast_true(var->value); } else if (!strcasecmp(var->name, "reportholdtime")) { - q->reportholdtime = ast_true(var->value); + q->flags.reportholdtime = ast_true(var->value); } else if (!strcasecmp(var->name, "memberdelay")) { q->memberdelay = atoi(var->value); } else if (!strcasecmp(var->name, "weight")) { @@ -2680,7 +2680,7 @@ if (q->weight) use_weight++; } else if (!strcasecmp(var->name, "timeoutrestart")) { - q->timeoutrestart = ast_true(var->value); + q->flags.timeoutrestart = ast_true(var->value); } else { ast_log(LOG_WARNING, "Unknown keyword in queue '%s': %s at line %d of queue.conf\n", cat, var->name, var->lineno); } @@ -2712,7 +2712,7 @@ ql = NULL; while(q) { qn = q->next; - if (q->dead) { + if (q->flags.dead) { if (ql) ql->next = q->next; else @@ -2804,7 +2804,7 @@ if(q->callscompleted > 0) sl = 100*((float)q->callscompletedinsl/(float)q->callscompleted); ast_cli(fd, "%-12.12s has %d calls (max %s) in '%s' strategy (%ds holdtime), W:%d, C:%d, A:%d, SL:%2.1f%% within %ds\n", - q->name, q->count, max, int2strat(q->strategy), q->holdtime, q->weight, q->callscompleted, q->callsabandoned,sl,q->servicelevel); + q->name, q->count, max, int2strat(q->flags.strategy), q->holdtime, q->weight, q->callscompleted, q->callsabandoned,sl,q->servicelevel); if (q->members) { ast_cli(fd, " Members: \n"); for (mem = q->members; mem; mem = mem->next) {