[asterisk-commits] file: trunk r55671 - in /trunk: ./ channels/chan_agent.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Feb 20 15:49:54 MST 2007


Author: file
Date: Tue Feb 20 16:49:53 2007
New Revision: 55671

URL: http://svn.digium.com/view/asterisk?view=rev&rev=55671
Log:
Merged revisions 55670 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r55670 | file | 2007-02-20 17:47:00 -0500 (Tue, 20 Feb 2007) | 10 lines

Merged revisions 55669 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r55669 | file | 2007-02-20 17:39:14 -0500 (Tue, 20 Feb 2007) | 2 lines

Defer clearing callback information if channels are up until they are hung up. This ensures the hangup process goes smoothly and no channels get hung in limbo. (issue #8088 reported by kebl0155)

........

................

Modified:
    trunk/   (props changed)
    trunk/channels/chan_agent.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_agent.c?view=diff&rev=55671&r1=55670&r2=55671
==============================================================================
--- trunk/channels/chan_agent.c (original)
+++ trunk/channels/chan_agent.c Tue Feb 20 16:49:53 2007
@@ -169,6 +169,7 @@
 	int abouttograb;               /*!< About to grab */
 	int autologoff;                /*!< Auto timeout time */
 	int ackcall;                   /*!< ackcall */
+	int deferlogoff;               /*!< Defer logoff to hangup */
 	time_t loginstart;             /*!< When agent first logged in (0 when logged off) */
 	time_t start;                  /*!< When call started */
 	struct timeval lastdisc;       /*!< When last disconnected */
@@ -765,10 +766,12 @@
 			}
 			if (option_debug)
 				ast_log(LOG_DEBUG, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
-			if (howlong  && p->autologoff && (howlong > p->autologoff)) {
+			if ((p->deferlogoff) || (howlong && p->autologoff && (howlong > p->autologoff))) {
 				long logintime = time(NULL) - p->loginstart;
 				p->loginstart = 0;
-				ast_log(LOG_NOTICE, "Agent '%s' didn't answer/confirm within %d seconds (waited %d)\n", p->name, p->autologoff, howlong);
+				if (!p->deferlogoff)
+					ast_log(LOG_NOTICE, "Agent '%s' didn't answer/confirm within %d seconds (waited %d)\n", p->name, p->autologoff, howlong);
+				p->deferlogoff = 0;
 				agent_logoff_maintenance(p, p->loginchan, logintime, ast->uniqueid, "Autologoff");
 			}
 		} else if (p->dead) {
@@ -1507,16 +1510,20 @@
 
 	AST_LIST_TRAVERSE(&agents, p, list) {
 		if (!strcasecmp(p->agent, agent)) {
-			if (!soft) {
-				if (p->owner)
-					ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT);
-				if (p->chan) 
-					ast_softhangup(p->chan, AST_SOFTHANGUP_EXPLICIT);
+			ret = 0;
+			if (p->owner || p->chan) {
+				p->deferlogoff = 1;
+				if (!soft) {
+					if (p->owner)
+						ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT);
+					if (p->chan)
+						ast_softhangup(p->chan, AST_SOFTHANGUP_EXPLICIT);
+				}
+			} else {
+				logintime = time(NULL) - p->loginstart;
+				p->loginstart = 0;
+				agent_logoff_maintenance(p, p->loginchan, logintime, NULL, "CommandLogoff");
 			}
-			ret = 0; /* found an agent => return 0 */
-			logintime = time(NULL) - p->loginstart;
-			p->loginstart = 0;
-			agent_logoff_maintenance(p, p->loginchan, logintime, NULL, "CommandLogoff");
 			break;
 		}
 	}



More information about the asterisk-commits mailing list