[asterisk-commits] jpeeler: branch 1.6.2 r241318 - in /branches/1.6.2: ./ channels/chan_agent.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 19 13:02:52 CST 2010


Author: jpeeler
Date: Tue Jan 19 13:02:47 2010
New Revision: 241318

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=241318
Log:
Merged revisions 241314 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r241314 | jpeeler | 2010-01-19 12:46:11 -0600 (Tue, 19 Jan 2010) | 20 lines
  
  Merged revisions 241227 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r241227 | jpeeler | 2010-01-19 11:22:18 -0600 (Tue, 19 Jan 2010) | 13 lines
    
    Fix deadlock in agent_read by removing call to agent_logoff.
    
    One must always lock the agents list lock before the agent private. agent_read
    locks the private immediately, so locking the agents list lock is not an
    option (which is what agent_logoff requires). Because agent_read already 
    has access to the agent private all that is necessary is to do the required
    hanging up that agent_logoff performed.
    
    (closes issue #16321)
    Reported by: valon24
    Patches: 
          bug16321.patch uploaded by jpeeler (license 325)
  ........
................

Modified:
    branches/1.6.2/   (props changed)
    branches/1.6.2/channels/chan_agent.c

Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.2/channels/chan_agent.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/channels/chan_agent.c?view=diff&rev=241318&r1=241317&r2=241318
==============================================================================
--- branches/1.6.2/channels/chan_agent.c (original)
+++ branches/1.6.2/channels/chan_agent.c Tue Jan 19 13:02:47 2010
@@ -578,7 +578,28 @@
 			if (p->autologoff && (howlong >= p->autologoff)) {
 				ast_log(LOG_NOTICE, "Agent '%s' didn't answer/confirm within %d seconds (waited %d)\n", p->name, p->autologoff, howlong);
 				agent_logoff_maintenance(p, p->loginchan, (cur_time - p->loginstart), ast->uniqueid, "Autologoff");
-				agent_logoff(p->agent, 0);
+				if (p->owner || p->chan) {
+					while (p->owner && ast_channel_trylock(p->owner)) {
+						DEADLOCK_AVOIDANCE(&p->lock);
+					}
+					if (p->owner) {
+						ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT);
+						ast_channel_unlock(p->owner);
+					}
+
+					while (p->chan && ast_channel_trylock(p->chan)) {
+						DEADLOCK_AVOIDANCE(&p->lock);
+					}
+					if (p->chan) {
+						ast_softhangup(p->chan, AST_SOFTHANGUP_EXPLICIT);
+						ast_channel_unlock(p->chan);
+					}
+				} else {
+					long logintime;
+					logintime = time(NULL) - p->loginstart;
+					p->loginstart = 0;
+					agent_logoff_maintenance(p, p->loginchan, logintime, NULL, "CommandLogoff");
+				}
 			}
 		}
 		switch (f->frametype) {




More information about the asterisk-commits mailing list