mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 16:21:01 +00:00
Merged revisions 101413-101414 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r101413 | russell | 2008-01-31 13:04:52 -0600 (Thu, 31 Jan 2008) | 2 lines Add missing locking to the find_agent() function. ........ r101414 | russell | 2008-01-31 13:07:46 -0600 (Thu, 31 Jan 2008) | 3 lines 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/trunk@101416 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -2242,6 +2242,9 @@ static int agent_devicestate(void *data)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \note This function expects the agent list to be locked
|
||||||
|
*/
|
||||||
static struct agent_pvt *find_agent(char *agentid)
|
static struct agent_pvt *find_agent(char *agentid)
|
||||||
{
|
{
|
||||||
struct agent_pvt *cur;
|
struct agent_pvt *cur;
|
||||||
@@ -2277,7 +2280,10 @@ static int function_agent(struct ast_channel *chan, const char *cmd, char *data,
|
|||||||
if (!args.item)
|
if (!args.item)
|
||||||
args.item = "status";
|
args.item = "status";
|
||||||
|
|
||||||
|
AST_LIST_LOCK(&agents);
|
||||||
|
|
||||||
if (!(agent = find_agent(args.agentid))) {
|
if (!(agent = find_agent(args.agentid))) {
|
||||||
|
AST_LIST_UNLOCK(&agents);
|
||||||
ast_log(LOG_WARNING, "Agent '%s' not found!\n", args.agentid);
|
ast_log(LOG_WARNING, "Agent '%s' not found!\n", args.agentid);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -2303,6 +2309,8 @@ static int function_agent(struct ast_channel *chan, const char *cmd, char *data,
|
|||||||
} else if (!strcasecmp(args.item, "exten"))
|
} else if (!strcasecmp(args.item, "exten"))
|
||||||
ast_copy_string(buf, agent->loginchan, len);
|
ast_copy_string(buf, agent->loginchan, len);
|
||||||
|
|
||||||
|
AST_LIST_UNLOCK(&agents);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user