mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 11:58:52 +00:00
Move the locking from find_agent() into the agent dialplan function handler to
ensure that the agent doesn't disappear while we're looking at it. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@101414 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -2568,16 +2568,17 @@ static int agent_devicestate(void *data)
|
||||
return res;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \note This function expects the agent list to be locked
|
||||
*/
|
||||
static struct agent_pvt *find_agent(char *agentid)
|
||||
{
|
||||
struct agent_pvt *cur;
|
||||
|
||||
AST_LIST_LOCK(&agents);
|
||||
AST_LIST_TRAVERSE(&agents, cur, list) {
|
||||
if (!strcmp(cur->agent, agentid))
|
||||
break;
|
||||
}
|
||||
AST_LIST_UNLOCK(&agents);
|
||||
|
||||
return cur;
|
||||
}
|
||||
@@ -2605,7 +2606,10 @@ static int function_agent(struct ast_channel *chan, char *cmd, char *data, char
|
||||
if (!args.item)
|
||||
args.item = "status";
|
||||
|
||||
AST_LIST_LOCK(&agents);
|
||||
|
||||
if (!(agent = find_agent(args.agentid))) {
|
||||
AST_LIST_UNLOCK(&agents);
|
||||
ast_log(LOG_WARNING, "Agent '%s' not found!\n", args.agentid);
|
||||
return -1;
|
||||
}
|
||||
@@ -2631,6 +2635,8 @@ static int function_agent(struct ast_channel *chan, char *cmd, char *data, char
|
||||
} else if (!strcasecmp(args.item, "exten"))
|
||||
ast_copy_string(buf, agent->loginchan, len);
|
||||
|
||||
AST_LIST_UNLOCK(&agents);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user