Rework sig_pri_hangup() to be simpler and clearer.

JIRA AST-675


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@336569 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2011-09-19 15:25:34 +00:00
parent 535817fe71
commit 9eb7ccef76

View File

@@ -6225,11 +6225,7 @@ void sig_pri_init_pri(struct sig_pri_span *pri)
int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast) int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast)
{ {
#ifdef SUPPORT_USERUSER ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
const char *useruser = pbx_builtin_getvar_helper(ast, "USERUSERINFO");
#endif
ast_log(LOG_DEBUG, "%s %d\n", __FUNCTION__, p->channel);
if (!ast->tech_pvt) { if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n"); ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0; return 0;
@@ -6252,42 +6248,42 @@ int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast)
p->exten[0] = '\0'; p->exten[0] = '\0';
sig_pri_set_dialing(p, 0); sig_pri_set_dialing(p, 0);
/* Make sure we have a call (or REALLY have a call in the case of a PRI) */ /* Make sure we really have a call */
pri_grab(p, p->pri); pri_grab(p, p->pri);
if (p->call) { if (p->call) {
if (p->alreadyhungup) { #if defined(SUPPORT_USERUSER)
ast_log(LOG_DEBUG, "Already hungup... Calling hangup once, and clearing call\n"); const char *useruser = pbx_builtin_getvar_helper(ast, "USERUSERINFO");
#ifdef SUPPORT_USERUSER if (!ast_strlen_zero(useruser)) {
pri_call_set_useruser(p->call, useruser); pri_call_set_useruser(p->call, useruser);
#endif }
#endif /* defined(SUPPORT_USERUSER) */
#if defined(HAVE_PRI_AOC_EVENTS) #if defined(HAVE_PRI_AOC_EVENTS)
if (p->holding_aoce) { if (p->holding_aoce) {
pri_aoc_e_send(p->pri->pri, p->call, &p->aoc_e); pri_aoc_e_send(p->pri->pri, p->call, &p->aoc_e);
} }
#endif /* defined(HAVE_PRI_AOC_EVENTS) */ #endif /* defined(HAVE_PRI_AOC_EVENTS) */
if (p->alreadyhungup) {
ast_debug(1, "Already hungup... Calling hangup once, and clearing call\n");
pri_hangup(p->pri->pri, p->call, -1); pri_hangup(p->pri->pri, p->call, -1);
p->call = NULL; p->call = NULL;
} else { } else {
const char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE"); const char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE");
int icause = ast->hangupcause ? ast->hangupcause : -1; int icause = ast->hangupcause ? ast->hangupcause : -1;
ast_log(LOG_DEBUG, "Not yet hungup... Calling hangup once with icause, and clearing call\n");
#ifdef SUPPORT_USERUSER
pri_call_set_useruser(p->call, useruser);
#endif
p->alreadyhungup = 1; p->alreadyhungup = 1;
if (cause) { if (!ast_strlen_zero(cause)) {
if (atoi(cause)) if (atoi(cause)) {
icause = atoi(cause); icause = atoi(cause);
}
} }
#if defined(HAVE_PRI_AOC_EVENTS) ast_debug(1,
if (p->holding_aoce) { "Not yet hungup... Calling hangup with cause %d, and clearing call\n",
pri_aoc_e_send(p->pri->pri, p->call, &p->aoc_e); icause);
}
#endif /* defined(HAVE_PRI_AOC_EVENTS) */
pri_hangup(p->pri->pri, p->call, icause); pri_hangup(p->pri->pri, p->call, icause);
} }
} }