mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
Try immediately logged in agents first, then callbacklogin ones
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1266 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -726,12 +726,14 @@ static struct ast_channel *agent_request(char *type, int format, void *data)
|
||||
} else {
|
||||
groupmatch = 0;
|
||||
}
|
||||
|
||||
/* Check actual logged in agents first */
|
||||
ast_pthread_mutex_lock(&agentlock);
|
||||
p = agents;
|
||||
while(p) {
|
||||
ast_pthread_mutex_lock(&p->lock);
|
||||
if (!p->pending && ((groupmatch && (p->group & groupmatch)) || !strcmp(data, p->agent)) &&
|
||||
!p->lastdisc.tv_sec) {
|
||||
!p->lastdisc.tv_sec && !strlen(p->loginchan)) {
|
||||
/* Agent must be registered, but not have any active call, and not be in a waiting state */
|
||||
if (!p->owner && p->chan) {
|
||||
/* Fixed agent */
|
||||
@@ -750,6 +752,32 @@ static struct ast_channel *agent_request(char *type, int format, void *data)
|
||||
ast_pthread_mutex_unlock(&p->lock);
|
||||
p = p->next;
|
||||
}
|
||||
if (!p) {
|
||||
p = agents;
|
||||
while(p) {
|
||||
ast_pthread_mutex_lock(&p->lock);
|
||||
if (!p->pending && ((groupmatch && (p->group & groupmatch)) || !strcmp(data, p->agent)) &&
|
||||
!p->lastdisc.tv_sec) {
|
||||
/* Agent must be registered, but not have any active call, and not be in a waiting state */
|
||||
if (!p->owner && p->chan) {
|
||||
/* Fixed agent */
|
||||
chan = agent_new(p, AST_STATE_DOWN);
|
||||
} else if (!p->owner && strlen(p->loginchan)) {
|
||||
/* Adjustable agent */
|
||||
p->chan = ast_request("Local", format, p->loginchan);
|
||||
if (p->chan)
|
||||
chan = agent_new(p, AST_STATE_DOWN);
|
||||
}
|
||||
if (chan) {
|
||||
ast_pthread_mutex_unlock(&p->lock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ast_pthread_mutex_unlock(&p->lock);
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (!chan && waitforagent) {
|
||||
/* No agent available -- but we're requesting to wait for one.
|
||||
Allocate a place holder */
|
||||
|
Reference in New Issue
Block a user