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;
}
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;
}
} else if (!strcasecmp(args.item, "exten"))
ast_copy_string(buf, agent->loginchan, len);
+ AST_LIST_UNLOCK(&agents);
+
return 0;
}