mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
chan_agent: Remove some duplicated code.
No need to check for an agent twice. Santa does that. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@378064 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1442,8 +1442,9 @@ static struct ast_channel *agent_request(const char *type, struct ast_format_cap
|
||||
AST_LIST_TRAVERSE(&agents, p, list) {
|
||||
ast_mutex_lock(&p->lock);
|
||||
if (!p->pending && ((groupmatch && (p->group & groupmatch)) || !strcmp(data, p->agent))) {
|
||||
if (p->chan)
|
||||
if (p->chan) {
|
||||
hasagent++;
|
||||
}
|
||||
now = ast_tvnow();
|
||||
if (!p->lastdisc.tv_sec || (now.tv_sec >= p->lastdisc.tv_sec)) {
|
||||
p->lastdisc = ast_tv(0, 0);
|
||||
@@ -1460,30 +1461,6 @@ static struct ast_channel *agent_request(const char *type, struct ast_format_cap
|
||||
}
|
||||
ast_mutex_unlock(&p->lock);
|
||||
}
|
||||
if (!p) {
|
||||
AST_LIST_TRAVERSE(&agents, p, list) {
|
||||
ast_mutex_lock(&p->lock);
|
||||
if (!p->pending && ((groupmatch && (p->group & groupmatch)) || !strcmp(data, p->agent))) {
|
||||
if (p->chan) {
|
||||
hasagent++;
|
||||
}
|
||||
now = ast_tvnow();
|
||||
if (!p->lastdisc.tv_sec || (now.tv_sec >= p->lastdisc.tv_sec)) {
|
||||
p->lastdisc = ast_tv(0, 0);
|
||||
/* Agent must be registered, but not have any active call, and not be in a waiting state */
|
||||
if (!p->owner && p->chan) {
|
||||
/* Could still get a fixed agent */
|
||||
chan = agent_new(p, AST_STATE_DOWN, requestor ? ast_channel_linkedid(requestor) : NULL, callid);
|
||||
}
|
||||
if (chan) {
|
||||
ast_mutex_unlock(&p->lock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ast_mutex_unlock(&p->lock);
|
||||
}
|
||||
}
|
||||
|
||||
if (!chan && waitforagent) {
|
||||
/* No agent available -- but we're requesting to wait for one.
|
||||
|
Reference in New Issue
Block a user