Fix for openzap sending CALL_STOPPED_ACK before clearing local channel
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@926 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
fb72b04010
commit
86832cb68c
|
@ -470,9 +470,7 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
|
|||
case ZAP_CHAN_TYPE_EM:
|
||||
case ZAP_CHAN_TYPE_CAS:
|
||||
{
|
||||
|
||||
zap_set_state_locked(tech_pvt->zchan, ZAP_CHANNEL_STATE_HANGUP);
|
||||
|
||||
}
|
||||
break;
|
||||
case ZAP_CHAN_TYPE_FXS:
|
||||
|
@ -488,10 +486,12 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
|
|||
break;
|
||||
case ZAP_CHAN_TYPE_B:
|
||||
{
|
||||
if (tech_pvt->zchan->state != ZAP_CHANNEL_STATE_DOWN && tech_pvt->zchan->state != ZAP_CHANNEL_STATE_TERMINATING) {
|
||||
tech_pvt->zchan->caller_data.hangup_cause = switch_channel_get_cause_q850(channel);
|
||||
if (tech_pvt->zchan->caller_data.hangup_cause < 1 || tech_pvt->zchan->caller_data.hangup_cause > 127) {
|
||||
tech_pvt->zchan->caller_data.hangup_cause = ZAP_CAUSE_DESTINATION_OUT_OF_ORDER;
|
||||
if (tech_pvt->zchan->state != ZAP_CHANNEL_STATE_DOWN) {
|
||||
if (tech_pvt->zchan->state != ZAP_CHANNEL_STATE_TERMINATING) {
|
||||
tech_pvt->zchan->caller_data.hangup_cause = switch_channel_get_cause_q850(channel);
|
||||
if (tech_pvt->zchan->caller_data.hangup_cause < 1 || tech_pvt->zchan->caller_data.hangup_cause > 127) {
|
||||
tech_pvt->zchan->caller_data.hangup_cause = ZAP_CAUSE_DESTINATION_OUT_OF_ORDER;
|
||||
}
|
||||
}
|
||||
zap_set_state_locked(tech_pvt->zchan, ZAP_CHANNEL_STATE_HANGUP);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ static time_t congestion_timeouts[MAX_TRUNK_GROUPS];
|
|||
*/
|
||||
typedef enum {
|
||||
SFLAG_FREE_REQ_ID = (1 << 0),
|
||||
SFLAG_SENT_FINAL_RESPONSE = (1 << 1)
|
||||
SFLAG_SENT_FINAL_MSG = (1 << 1)
|
||||
} sflag_t;
|
||||
|
||||
typedef uint16_t sangoma_boost_request_id_t;
|
||||
|
@ -472,6 +472,9 @@ static void handle_call_progress(sangomabc_connection_t *mcon, sangomabc_short_e
|
|||
|
||||
|
||||
zap_log(ZAP_LOG_CRIT, "START PROGRESS CANT FIND A CHAN %d:%d\n", event->span+1,event->chan+1);
|
||||
|
||||
zap_set_sflag(zchan, SFLAG_SENT_FINAL_MSG);
|
||||
|
||||
sangomabc_exec_command(mcon,
|
||||
event->span,
|
||||
event->chan,
|
||||
|
@ -517,7 +520,7 @@ static void handle_call_start_ack(sangomabc_connection_t *mcon, sangomabc_short_
|
|||
//printf("WTF BAD ACK2 %d:%d (%d:%d) CSid=%d xtra_id=%d out=%d state=%s\n", zchan->span_id, zchan->chan_id, event->span+1,event->chan+1, event->call_setup_id, zchan->extra_id, zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND), zap_channel_state2str(zchan->state));
|
||||
}
|
||||
|
||||
|
||||
zap_set_sflag(zchan, SFLAG_SENT_FINAL_MSG);
|
||||
zap_log(ZAP_LOG_CRIT, "START ACK CANT FIND A CHAN %d:%d\n", event->span+1,event->chan+1);
|
||||
sangomabc_exec_command(mcon,
|
||||
event->span,
|
||||
|
@ -636,10 +639,9 @@ static void handle_call_start_nack(zap_span_t *span, sangomabc_connection_t *mco
|
|||
}
|
||||
|
||||
if (zchan) {
|
||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_MSG);
|
||||
}
|
||||
|
||||
|
||||
/* nobody else will do it so we have to do it ourselves */
|
||||
sangomabc_exec_command(mcon,
|
||||
event->span,
|
||||
|
@ -674,22 +676,12 @@ static void handle_call_stop(zap_span_t *span, sangomabc_connection_t *mcon, san
|
|||
}
|
||||
|
||||
zap_mutex_unlock(zchan->mutex);
|
||||
|
||||
if (r) {
|
||||
return;
|
||||
}
|
||||
} /* else we have to do it ourselves.... */
|
||||
|
||||
if (zchan) {
|
||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
||||
}
|
||||
|
||||
sangomabc_exec_command(mcon,
|
||||
event->span,
|
||||
event->chan,
|
||||
0,
|
||||
SIGBOOST_EVENT_CALL_STOPPED_ACK,
|
||||
0);
|
||||
zap_log(ZAP_LOG_WARNING, "We could not find chan: s%dc%d\n", event->span, event->chan);
|
||||
|
||||
release_request_id_span_chan(event->span, event->chan);
|
||||
}
|
||||
|
@ -983,7 +975,18 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
|||
}
|
||||
|
||||
zchan->sflags = 0;
|
||||
zap_channel_done(zchan);
|
||||
|
||||
if (!zap_test_sflag(zchan, SFLAG_SENT_FINAL_MSG)) {
|
||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_MSG);
|
||||
|
||||
sangomabc_exec_command(mcon,
|
||||
zchan->physical_span_id-1,
|
||||
zchan->physical_chan_id-1,
|
||||
0,
|
||||
SIGBOOST_EVENT_CALL_STOPPED_ACK,
|
||||
0);
|
||||
}
|
||||
zap_channel_done(zchan);
|
||||
}
|
||||
break;
|
||||
case ZAP_CHANNEL_STATE_PROGRESS_MEDIA:
|
||||
|
@ -1019,9 +1022,8 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
|||
{
|
||||
sig.event_id = ZAP_SIGEVENT_RESTART;
|
||||
status = sangoma_boost_data->signal_cb(&sig);
|
||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_MSG);
|
||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
|
||||
|
||||
}
|
||||
break;
|
||||
case ZAP_CHANNEL_STATE_UP:
|
||||
|
@ -1035,7 +1037,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
|||
if (!(zap_test_flag(zchan, ZAP_CHANNEL_PROGRESS) || zap_test_flag(zchan, ZAP_CHANNEL_MEDIA))) {
|
||||
sangomabc_exec_command(mcon,
|
||||
zchan->physical_span_id-1,
|
||||
zchan->physical_chan_id-1,
|
||||
zchan->physical_chan_id-1,
|
||||
0,
|
||||
SIGBOOST_EVENT_CALL_START_ACK,
|
||||
0);
|
||||
|
@ -1043,7 +1045,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
|||
|
||||
sangomabc_exec_command(mcon,
|
||||
zchan->physical_span_id-1,
|
||||
zchan->physical_chan_id-1,
|
||||
zchan->physical_chan_id-1,
|
||||
0,
|
||||
SIGBOOST_EVENT_CALL_ANSWERED,
|
||||
0);
|
||||
|
@ -1061,11 +1063,11 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
|||
break;
|
||||
case ZAP_CHANNEL_STATE_HANGUP:
|
||||
{
|
||||
if (zap_test_sflag(zchan, SFLAG_SENT_FINAL_RESPONSE)) {
|
||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
|
||||
if (zchan->last_state == ZAP_CHANNEL_STATE_TERMINATING ||
|
||||
zap_test_sflag(zchan, SFLAG_SENT_FINAL_MSG)) {
|
||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP_COMPLETE);
|
||||
} else {
|
||||
|
||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_MSG);
|
||||
if (zap_test_flag(zchan, ZAP_CHANNEL_ANSWERED) || zap_test_flag(zchan, ZAP_CHANNEL_PROGRESS) || zap_test_flag(zchan, ZAP_CHANNEL_MEDIA)) {
|
||||
sangomabc_exec_command(mcon,
|
||||
zchan->physical_span_id-1,
|
||||
|
@ -1089,7 +1091,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
|||
sig.event_id = ZAP_SIGEVENT_STOP;
|
||||
status = sangoma_boost_data->signal_cb(&sig);
|
||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
|
||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_MSG);
|
||||
sangomabc_exec_command(mcon,
|
||||
zchan->physical_span_id-1,
|
||||
zchan->physical_chan_id-1,
|
||||
|
@ -1100,17 +1102,9 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
|||
break;
|
||||
case ZAP_CHANNEL_STATE_TERMINATING:
|
||||
{
|
||||
|
||||
sig.event_id = ZAP_SIGEVENT_STOP;
|
||||
status = sangoma_boost_data->signal_cb(&sig);
|
||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP_COMPLETE);
|
||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
||||
sangomabc_exec_command(mcon,
|
||||
zchan->physical_span_id-1,
|
||||
zchan->physical_chan_id-1,
|
||||
0,
|
||||
SIGBOOST_EVENT_CALL_STOPPED_ACK,
|
||||
0);
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -1428,7 +1422,7 @@ static zap_state_map_t boost_state_map = {
|
|||
ZSD_OUTBOUND,
|
||||
ZSM_UNACCEPTABLE,
|
||||
{ZAP_CHANNEL_STATE_HANGUP, ZAP_CHANNEL_STATE_TERMINATING, ZAP_END},
|
||||
{ZAP_CHANNEL_STATE_HANGUP_COMPLETE, ZAP_END}
|
||||
{ZAP_CHANNEL_STATE_HANGUP_COMPLETE, ZAP_CHANNEL_STATE_HANGUP, ZAP_END}
|
||||
},
|
||||
{
|
||||
ZSD_OUTBOUND,
|
||||
|
@ -1472,7 +1466,7 @@ static zap_state_map_t boost_state_map = {
|
|||
ZSD_INBOUND,
|
||||
ZSM_UNACCEPTABLE,
|
||||
{ZAP_CHANNEL_STATE_HANGUP, ZAP_CHANNEL_STATE_TERMINATING, ZAP_END},
|
||||
{ZAP_CHANNEL_STATE_HANGUP_COMPLETE, ZAP_END},
|
||||
{ZAP_CHANNEL_STATE_HANGUP_COMPLETE, ZAP_CHANNEL_STATE_HANGUP, ZAP_END},
|
||||
},
|
||||
{
|
||||
ZSD_INBOUND,
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "openzap.h"
|
||||
#include <sangoma_boost_client.h>
|
||||
|
||||
|
||||
#ifndef HAVE_GETHOSTBYNAME_R
|
||||
extern int gethostbyname_r (const char *__name,
|
||||
struct hostent *__result_buf,
|
||||
|
@ -76,16 +75,17 @@ static void sangomabc_print_event_call(sangomabc_connection_t *mcon, sangomabc_e
|
|||
{
|
||||
if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
|
||||
return;
|
||||
|
||||
zap_log(file, func, line, ZAP_LOG_LEVEL_WARNING, "%s EVENT: %s:(%X) [w%dg%d] CSid=%i Seq=%i Cn=[%s] Cd=[%s] Ci=[%s] Rdnis=[%s]\n",
|
||||
dir ? "TX":"RX",
|
||||
sangomabc_event_id_name(event->event_id),
|
||||
event->event_id,
|
||||
event->span+1,
|
||||
event->chan+1,
|
||||
event->call_setup_id,
|
||||
event->fseqno,
|
||||
strlen(event->calling_name)?event->calling_name:"N/A",
|
||||
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
||||
sangomabc_event_id_name(event->event_id),
|
||||
event->event_id,
|
||||
event->span+1,
|
||||
event->chan+1,
|
||||
event->call_setup_id,
|
||||
event->fseqno,
|
||||
strlen(event->calling_name)?event->calling_name:"N/A",
|
||||
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
||||
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A"),
|
||||
event->isup_in_rdnis);
|
||||
|
||||
|
|
Loading…
Reference in New Issue