aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_zap.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-09-26 03:14:44 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-09-26 03:14:44 +0000
commit91b64633f77172d7ee2312517d4f8a5e9dfea09e (patch)
tree63d59e9f0165943f5414ba46621ca5715fd80932 /channels/chan_zap.c
parent3c9fd0862cb0e0e0904393c4cf2b662bff9f4264 (diff)
handle polarity reversal hangup indication during an incoming call that is still ringing (issue #5191)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6661 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_zap.c')
-rwxr-xr-xchannels/chan_zap.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index ed15c038d..c8a897351 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -4140,37 +4140,44 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
}
break;
case ZT_EVENT_POLARITY:
- /*
- * If we get a Polarity Switch event, check to see
- * if we should change the polarity state and
- * mark the channel as UP or if this is an indication
- * of remote end disconnect.
- */
- if (p->polarity == POLARITY_IDLE) {
- p->polarity = POLARITY_REV;
- if (p->answeronpolarityswitch &&
- ((ast->_state == AST_STATE_DIALING) ||
- (ast->_state == AST_STATE_RINGING))) {
- ast_log(LOG_DEBUG, "Answering on polarity switch!\n");
- ast_setstate(p->owner, AST_STATE_UP);
- } else
- ast_log(LOG_DEBUG, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state);
- } else if(p->hanguponpolarityswitch &&
+ /*
+ * If we get a Polarity Switch event, check to see
+ * if we should change the polarity state and
+ * mark the channel as UP or if this is an indication
+ * of remote end disconnect.
+ */
+ if (p->polarity == POLARITY_IDLE) {
+ p->polarity = POLARITY_REV;
+ if (p->answeronpolarityswitch &&
+ ((ast->_state == AST_STATE_DIALING) ||
+ (ast->_state == AST_STATE_RINGING))) {
+ ast_log(LOG_DEBUG, "Answering on polarity switch!\n");
+ ast_setstate(p->owner, AST_STATE_UP);
+ } else
+ ast_log(LOG_DEBUG, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state);
+ }
+ /* Removed else statement from here as it was preventing hangups from ever happening*/
+ /* Added AST_STATE_RING in if statement below to deal with calling party hangups that take place when ringing */
+ if(p->hanguponpolarityswitch &&
(p->polarityonanswerdelay > 0) &&
- (p->polarity == POLARITY_REV) &&
- (ast->_state == AST_STATE_UP)) {
-
+ (p->polarity == POLARITY_REV) &&
+ ((ast->_state == AST_STATE_UP) || (ast->_state == AST_STATE_RING)) ) {
+ /* Added log_debug information below to provide a better indication of what is going on */
+ ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+
if(ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) > p->polarityonanswerdelay) {
- ast_log(LOG_DEBUG, "Hangup due to Reverse Polarity on channel %d\n", p->channel);
+ ast_log(LOG_DEBUG, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel);
ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT);
p->polarity = POLARITY_IDLE;
} else {
- ast_log(LOG_DEBUG, "Ignore Reverse Polarity (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state);
+ ast_log(LOG_DEBUG, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state);
}
} else {
p->polarity = POLARITY_IDLE;
- ast_log(LOG_DEBUG, "Ignore switch to IDLE Polarity on channel %d, state %d\n", p->channel, ast->_state);
+ ast_log(LOG_DEBUG, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state);
}
+ /* Added more log_debug information below to provide a better indication of what is going on */
+ ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
break;
default:
ast_log(LOG_DEBUG, "Dunno what to do with event %d on channel %d\n", res, p->channel);
@@ -4180,6 +4187,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
+
static struct ast_frame *__zt_exception(struct ast_channel *ast)
{
struct zt_pvt *p = ast->tech_pvt;