diff options
Diffstat (limited to 'apps/app_dial.c')
-rw-r--r-- | apps/app_dial.c | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c index 6c835fcec..97186f275 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -1788,7 +1788,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags } res = ast_bridge_call(chan,peer,&config); time(&end_time); - { + if (res != AST_PBX_KEEPALIVE) { /* if keepalive is set, don't even think about accessing chan! */ char toast[80]; snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time)); pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", toast); @@ -1797,36 +1797,40 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags time(&end_time); res = -1; } - { + if (res != AST_PBX_KEEPALIVE) { /* if keepalive is set, don't even think about accessing chan! */ char toast[80]; snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time)); pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast); } - - if (res != AST_PBX_NO_HANGUP_PEER) { - if (!chan->_softhangup) + if (res != AST_PBX_NO_HANGUP_PEER && res != AST_PBX_NO_HANGUP_PEER_PARKED) { + if (res != AST_PBX_KEEPALIVE && !chan->_softhangup) chan->hangupcause = peer->hangupcause; ast_hangup(peer); } } out: - if (moh) { - moh = 0; - ast_moh_stop(chan); - } else if (sentringing) { - sentringing = 0; - ast_indicate(chan, -1); - } - ast_rtp_early_bridge(chan, NULL); - hanguptree(outgoing, NULL); - pbx_builtin_setvar_helper(chan, "DIALSTATUS", status); - if (option_debug) - ast_log(LOG_DEBUG, "Exiting with DIALSTATUS=%s.\n", status); - - if ((ast_test_flag(peerflags, OPT_GO_ON)) && (!chan->_softhangup) && (res != AST_PBX_KEEPALIVE)) { - if (calldurationlimit) - chan->whentohangup = 0; - res = 0; + /* cleaning up chan is not a good idea here if AST_PBX_KEEPALIVE + is returned; chan will get the love it needs from another + thread */ + if (res != AST_PBX_KEEPALIVE) { + if (moh) { + moh = 0; + ast_moh_stop(chan); + } else if (sentringing) { + sentringing = 0; + ast_indicate(chan, -1); + } + ast_rtp_early_bridge(chan, NULL); + hanguptree(outgoing, NULL); + pbx_builtin_setvar_helper(chan, "DIALSTATUS", status); + if (option_debug) + ast_log(LOG_DEBUG, "Exiting with DIALSTATUS=%s.\n", status); + + if ((ast_test_flag(peerflags, OPT_GO_ON)) && (!chan->_softhangup) && (res != AST_PBX_KEEPALIVE)) { + if (calldurationlimit) + chan->whentohangup = 0; + res = 0; + } } done: |