From ab96ee237bcfc826d0347d720fe743d83e042d63 Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Tue, 20 Feb 2007 22:49:53 +0000 Subject: [PATCH] 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) ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@55671 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_agent.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/channels/chan_agent.c b/channels/chan_agent.c index e097f7bf49..453e8a4140 100644 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -169,6 +169,7 @@ struct agent_pvt { 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 @@ static int agent_hangup(struct ast_channel *ast) } 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 @@ static int agent_logoff(const char *agent, int soft) 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; } }