diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-10-16 15:35:23 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-10-16 15:35:23 +0000 |
commit | b99854e277156f8419a618b6870a875dc42533f9 (patch) | |
tree | 9d0d52c8ba9d22b789e2c2286a77550bc7bce033 /channels/chan_agent.c | |
parent | ed6bc742d3ae13f2fadcddc1790aa1007710bb4f (diff) |
Fix hangup handling with chansiavail with agent (bug #2658)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/v1-0@4016 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_agent.c')
-rwxr-xr-x | channels/chan_agent.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c index c5dcc891e..6e8c3661a 100755 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -519,9 +519,22 @@ static int agent_hangup(struct ast_channel *ast) ast->pvt->pvt = NULL; p->app_sleep_cond = 1; p->acknowledged = 0; - if (p->start && (ast->_state != AST_STATE_UP)) + + /* if they really are hung up then set start to 0 so the test + * later if we're called on an already downed channel + * doesn't cause an agent to be logged out like when + * agent_request() is followed immediately by agent_hangup() + * as in apps/app_chanisavail.c:chanavail_exec() + */ + + ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state)); + if (p->start && (ast->_state != AST_STATE_UP)) { howlong = time(NULL) - p->start; - time(&p->start); + p->start = 0; + } else if (ast->_state == AST_STATE_RESERVED) { + howlong = 0; + } else + p->start = 0; if (p->chan) { /* If they're dead, go ahead and hang up on the agent now */ if (!ast_strlen_zero(p->loginchan)) { |