aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_agent.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-01-27 21:55:08 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-01-27 21:55:08 +0000
commitd2a1102815120fa87677531f844ecea1962d3ca0 (patch)
tree6d22d75cd38f8462682062694ac96c179d850d56 /channels/chan_agent.c
parentc9b68664c957fa8e4d90666ef2f09800d656e491 (diff)
Fix devicestate problems for "always-on" agent channels
A revision to chan_agent attempted to "inherit" the device state of the underlying channel in order to report the device state of an agent channel more accurately. The problem with the logic here is that it makes no sense to use this for always-on agents. If the agent is logged in, then to the underlying channel, the agent will always appear to be "in use," no matter if the agent is on a call or not. The reason is that to the underlying channel, the channel is currently in use on a call to the AgentLogin application. The most common cause that I found for this issue to occur was for a SIP channel to be the underlying channel type for an Agent channel. If the SIP phone re-registers, then the registration will cause the device state core to query the device state of the SIP channel. Since the SIP channel is in use, the Agent channel would also inherit this status. Once the agent channel was set to "in use" there was no way that the device state could change on that channel unless the agent logged out. The solution for this problem is a bit different in 1.4 than it is in the other branches. In 1.4, there will be a one-line fix to make sure that only callback agents will inherit device state from their underlying channel type. For the other branches of Asterisk, since callback support has been removed, there is also no need for device state inheritance in chan_agent, so I will simply be removing it from the code. In addition, the 1.4 source is getting a new comment to help the next person who edits chan_agent.c. I'm adding a comment that a agent_pvt's loginchan field may be used to determine if the agent is a callback agent or not. (closes issue #14173) Reported by: nathan Patches: 14173.patch uploaded by putnopvut (license 60) Tested by: nathan, aramirez git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@171689 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_agent.c')
-rw-r--r--channels/chan_agent.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index b12983dfc..6f9168a81 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -199,7 +199,10 @@ struct agent_pvt {
ast_cond_t app_complete_cond;
volatile int app_sleep_cond; /**< Sleep condition for the login app */
struct ast_channel *owner; /**< Agent */
- char loginchan[80]; /**< channel they logged in from */
+ /**! channel they logged in from. This may also be used to tell if an agent
+ * is a callback agent or not. If this field is not zero-length, then this is
+ * a callback agent */
+ char loginchan[80];
char logincallerid[80]; /**< Caller ID they had when they logged in */
struct ast_channel *chan; /**< Channel we use */
AST_LIST_ENTRY(agent_pvt) list; /**< Next Agent in the linked list. */
@@ -307,7 +310,7 @@ static int agent_devicestate_cb(const char *dev, int state, void *data)
AST_LIST_TRAVERSE(&agents, p, list) {
ast_mutex_lock(&p->lock);
- if (p->chan) {
+ if (p->chan && !ast_strlen_zero(p->loginchan)) {
ast_copy_string(basename, p->chan->name, sizeof(basename));
if ((tmp = strrchr(basename, '-'))) {
*tmp = '\0';