mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
Compute queue caller's timeout just once (bug #3091, with mods)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4490 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -191,7 +191,7 @@ struct queue_ent {
|
|||||||
int opos; /* Where we started in the queue */
|
int opos; /* Where we started in the queue */
|
||||||
int handled; /* Whether our call was handled */
|
int handled; /* Whether our call was handled */
|
||||||
time_t start; /* When we started holding */
|
time_t start; /* When we started holding */
|
||||||
int queuetimeout; /* How many seconds before timing out of queue */
|
time_t expire; /* When this entry should expire (time out of queue) */
|
||||||
struct ast_channel *chan; /* Our channel */
|
struct ast_channel *chan; /* Our channel */
|
||||||
struct queue_ent *next; /* The next queue entry */
|
struct queue_ent *next; /* The next queue entry */
|
||||||
};
|
};
|
||||||
@@ -1138,7 +1138,6 @@ static int wait_our_turn(struct queue_ent *qe, int ringing)
|
|||||||
{
|
{
|
||||||
struct queue_ent *ch;
|
struct queue_ent *ch;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
time_t now;
|
|
||||||
|
|
||||||
/* This is the holding pen for callers 2 through maxlen */
|
/* This is the holding pen for callers 2 through maxlen */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -1153,11 +1152,8 @@ static int wait_our_turn(struct queue_ent *qe, int ringing)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If we have timed out, break out */
|
/* If we have timed out, break out */
|
||||||
if ( qe->queuetimeout ) {
|
if (qe->expire && (time(NULL) > qe->expire))
|
||||||
time(&now);
|
|
||||||
if ( (now - qe->start) >= qe->queuetimeout )
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
/* leave the queue if no agents, if enabled */
|
/* leave the queue if no agents, if enabled */
|
||||||
if (has_no_members(qe->parent) && qe->parent->leavewhenempty) {
|
if (has_no_members(qe->parent) && qe->parent->leavewhenempty) {
|
||||||
@@ -1918,6 +1914,7 @@ static int queue_exec(struct ast_channel *chan, void *data)
|
|||||||
struct localuser *u;
|
struct localuser *u;
|
||||||
char *queuename;
|
char *queuename;
|
||||||
char info[512];
|
char info[512];
|
||||||
|
char *info_ptr = info;
|
||||||
char *options = NULL;
|
char *options = NULL;
|
||||||
char *url = NULL;
|
char *url = NULL;
|
||||||
char *announceoverride = NULL;
|
char *announceoverride = NULL;
|
||||||
@@ -1940,35 +1937,21 @@ static int queue_exec(struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
/* Setup our queue entry */
|
/* Setup our queue entry */
|
||||||
memset(&qe, 0, sizeof(qe));
|
memset(&qe, 0, sizeof(qe));
|
||||||
|
qe.start = time(NULL);
|
||||||
|
|
||||||
/* Parse our arguments XXX Check for failure XXX */
|
/* Parse our arguments XXX Check for failure XXX */
|
||||||
strncpy(info, (char *)data, strlen((char *)data) + AST_MAX_EXTENSION-1);
|
strncpy(info, (char *) data, sizeof(info) - 1);
|
||||||
queuename = info;
|
queuename = strsep(&info_ptr, "|");
|
||||||
if (queuename) {
|
options = strsep(&info_ptr, "|");
|
||||||
options = strchr(queuename, '|');
|
url = strsep(&info_ptr, "|");
|
||||||
if (options) {
|
announceoverride = strsep(&info_ptr, "|");
|
||||||
*options = '\0';
|
queuetimeoutstr = info_ptr;
|
||||||
options++;
|
|
||||||
url = strchr(options, '|');
|
/* set the expire time based on the supplied timeout; */
|
||||||
if (url) {
|
if (queuetimeoutstr)
|
||||||
*url = '\0';
|
qe.expire = qe.start + atoi(queuetimeoutstr);
|
||||||
url++;
|
else
|
||||||
announceoverride = strchr(url, '|');
|
qe.expire = 0;
|
||||||
if (announceoverride) {
|
|
||||||
*announceoverride = '\0';
|
|
||||||
announceoverride++;
|
|
||||||
queuetimeoutstr = strchr(announceoverride, '|');
|
|
||||||
if (queuetimeoutstr) {
|
|
||||||
*queuetimeoutstr = '\0';
|
|
||||||
queuetimeoutstr++;
|
|
||||||
qe.queuetimeout = atoi(queuetimeoutstr);
|
|
||||||
} else {
|
|
||||||
qe.queuetimeout = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the priority from the variable ${QUEUE_PRIO} */
|
/* Get the priority from the variable ${QUEUE_PRIO} */
|
||||||
user_priority = pbx_builtin_getvar_helper(chan, "QUEUE_PRIO");
|
user_priority = pbx_builtin_getvar_helper(chan, "QUEUE_PRIO");
|
||||||
@@ -1995,11 +1978,10 @@ static int queue_exec(struct ast_channel *chan, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if (option_debug) */
|
/* if (option_debug) */
|
||||||
ast_log(LOG_DEBUG, "queue: %s, options: %s, url: %s, announce: %s, timeout: %d, priority: %d\n",
|
ast_log(LOG_DEBUG, "queue: %s, options: %s, url: %s, announce: %s, expires: %ld, priority: %d\n",
|
||||||
queuename, options, url, announceoverride, qe.queuetimeout, (int)prio);
|
queuename, options, url, announceoverride, (long)qe.expire, (int)prio);
|
||||||
|
|
||||||
qe.chan = chan;
|
qe.chan = chan;
|
||||||
qe.start = time(NULL);
|
|
||||||
qe.prio = (int)prio;
|
qe.prio = (int)prio;
|
||||||
qe.last_pos_said = 0;
|
qe.last_pos_said = 0;
|
||||||
qe.last_pos = 0;
|
qe.last_pos = 0;
|
||||||
@@ -2043,7 +2025,7 @@ check_turns:
|
|||||||
/* or, they may timeout. */
|
/* or, they may timeout. */
|
||||||
|
|
||||||
/* Leave if we have exceeded our queuetimeout */
|
/* Leave if we have exceeded our queuetimeout */
|
||||||
if (qe.queuetimeout && ( (time(NULL) - qe.start) >= qe.queuetimeout) ) {
|
if (qe.expire && (time(NULL) > qe.expire)) {
|
||||||
res = 0;
|
res = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2073,7 +2055,7 @@ check_turns:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Leave if we have exceeded our queuetimeout */
|
/* Leave if we have exceeded our queuetimeout */
|
||||||
if (qe.queuetimeout && ( (time(NULL) - qe.start) >= qe.queuetimeout) ) {
|
if (qe.expire && (time(NULL) > qe.expire)) {
|
||||||
res = 0;
|
res = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user