[asterisk-commits] file: branch 1.4 r55670 - in /branches/1.4: ./ channels/chan_agent.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Feb 20 15:47:00 MST 2007


Author: file
Date: Tue Feb 20 16:47:00 2007
New Revision: 55670

URL: http://svn.digium.com/view/asterisk?view=rev&rev=55670
Log:
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:
    branches/1.4/   (props changed)
    branches/1.4/channels/chan_agent.c

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

Modified: branches/1.4/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_agent.c?view=diff&rev=55670&r1=55669&r2=55670
==============================================================================
--- branches/1.4/channels/chan_agent.c (original)
+++ branches/1.4/channels/chan_agent.c Tue Feb 20 16:47:00 2007
@@ -179,6 +179,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 */
@@ -770,10 +771,12 @@
 				p->chan = NULL;
 			}
 			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) {
@@ -1513,16 +1516,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