[Asterisk-cvs] asterisk/channels chan_agent.c,1.83,1.84

markster at lists.digium.com markster at lists.digium.com
Sat Oct 16 11:02:01 CDT 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv26573/channels

Modified Files:
	chan_agent.c 
Log Message:
Fix hangup handling with chansiavail with agent (bug #2658)


Index: chan_agent.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_agent.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- chan_agent.c	3 Oct 2004 04:19:58 -0000	1.83
+++ chan_agent.c	16 Oct 2004 15:01:59 -0000	1.84
@@ -525,9 +525,22 @@
 	ast->pvt->pvt = NULL;
 	p->app_sleep_cond = 1;
 	p->acknowledged = 0;
-	if (p->start && (ast->_state != AST_STATE_UP))
+
+	/* if they really are hung up then set start to 0 so the test
+	 * later if we're called on an already downed channel
+	 * doesn't cause an agent to be logged out like when
+	 * agent_request() is followed immediately by agent_hangup()
+	 * as in apps/app_chanisavail.c:chanavail_exec()
+	 */
+
+	ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state));
+	if (p->start && (ast->_state != AST_STATE_UP)) {
 		howlong = time(NULL) - p->start;
-	time(&p->start);
+		p->start = 0;
+	} else if (ast->_state == AST_STATE_RESERVED) {
+		howlong = 0;
+	} else
+		p->start = 0; 
 	if (p->chan) {
 		/* If they're dead, go ahead and hang up on the agent now */
 		if (!ast_strlen_zero(p->loginchan)) {




More information about the svn-commits mailing list