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/branches/1.2@55669 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2007-02-20 22:39:14 +00:00
parent 82bc576ea4
commit 960d22deb4

View File

@@ -790,6 +790,9 @@ static int agent_hangup(struct ast_channel *ast)
p->logincallerid[0] = '\0'; p->logincallerid[0] = '\0';
if (persistent_agents) if (persistent_agents)
dump_agents(); dump_agents();
} else if (!p->loginstart) {
p->loginchan[0] = '\0';
p->logincallerid[0] = '\0';
} }
} else if (p->dead) { } else if (p->dead) {
ast_mutex_lock(&p->chan->lock); ast_mutex_lock(&p->chan->lock);
@@ -1473,14 +1476,17 @@ static int agent_logoff(char *agent, int soft)
struct agent_pvt *p; struct agent_pvt *p;
long logintime; long logintime;
int ret = -1; /* Return -1 if no agent if found */ int ret = -1; /* Return -1 if no agent if found */
int defer = 0;
for (p=agents; p; p=p->next) { for (p=agents; p; p=p->next) {
if (!strcasecmp(p->agent, agent)) { if (!strcasecmp(p->agent, agent)) {
if (!soft) { if (!soft) {
if (p->owner) { if (p->owner) {
defer = 1;
ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT); ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT);
} }
if (p->chan) { if (p->chan) {
defer = 1;
ast_softhangup(p->chan, AST_SOFTHANGUP_EXPLICIT); ast_softhangup(p->chan, AST_SOFTHANGUP_EXPLICIT);
} }
} }
@@ -1495,8 +1501,10 @@ static int agent_logoff(char *agent, int soft)
p->agent, p->loginchan, logintime); p->agent, p->loginchan, logintime);
ast_queue_log("NONE", "NONE", agent, "AGENTCALLBACKLOGOFF", "%s|%ld|%s", p->loginchan, logintime, "CommandLogoff"); ast_queue_log("NONE", "NONE", agent, "AGENTCALLBACKLOGOFF", "%s|%ld|%s", p->loginchan, logintime, "CommandLogoff");
set_agentbycallerid(p->logincallerid, NULL); set_agentbycallerid(p->logincallerid, NULL);
p->loginchan[0] = '\0'; if (!defer) {
p->logincallerid[0] = '\0'; p->loginchan[0] = '\0';
p->logincallerid[0] = '\0';
}
ast_device_state_changed("Agent/%s", p->agent); ast_device_state_changed("Agent/%s", p->agent);
if (persistent_agents) if (persistent_agents)
dump_agents(); dump_agents();