[asterisk-commits] mmichelson: branch 1.4 r171689 - /branches/1.4/channels/chan_agent.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 27 15:55:09 CST 2009


Author: mmichelson
Date: Tue Jan 27 15:55:08 2009
New Revision: 171689

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=171689
Log:
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


Modified:
    branches/1.4/channels/chan_agent.c

Modified: branches/1.4/channels/chan_agent.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/channels/chan_agent.c?view=diff&rev=171689&r1=171688&r2=171689
==============================================================================
--- branches/1.4/channels/chan_agent.c (original)
+++ branches/1.4/channels/chan_agent.c Tue Jan 27 15:55:08 2009
@@ -199,7 +199,10 @@
 	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 @@
 
 	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';




More information about the asterisk-commits mailing list