From a9953ac8e165ed958d8c25da32ed60457ec399a8 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Thu, 21 Jan 2010 05:35:53 +0000 Subject: [PATCH] fix last commit typos and return hangup cause on failure in funky pri boost early media fail scenario git-svn-id: http://svn.openzap.org/svn/openzap/trunk@994 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/openzap/mod_openzap/mod_openzap.c | 7 ++++- .../ozmod_sangoma_boost/ozmod_sangoma_boost.c | 30 +++++++++++++------ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/libs/openzap/mod_openzap/mod_openzap.c b/libs/openzap/mod_openzap/mod_openzap.c index ff5a564d51..a3539d755e 100644 --- a/libs/openzap/mod_openzap/mod_openzap.c +++ b/libs/openzap/mod_openzap/mod_openzap.c @@ -1160,7 +1160,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi if (status != ZAP_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No channels available\n"); - return SWITCH_CAUSE_NORMAL_CIRCUIT_CONGESTION; + + if (caller_data.hangup_cause == SWITCH_CAUSE_NONE) { + caller_data.hangup_cause = SWITCH_CAUSE_NORMAL_CIRCUIT_CONGESTION; + } + + return caller_data.hangup_cause; } if ((var = switch_event_get_header(var_event, "openzap_pre_buffer_size"))) { diff --git a/libs/openzap/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c b/libs/openzap/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c index a863c68d67..afb9e97fd5 100644 --- a/libs/openzap/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c +++ b/libs/openzap/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c @@ -71,6 +71,7 @@ typedef struct { sangomabc_short_event_t event; zap_span_t *span; zap_channel_t *zchan; + int hangup_cause; } sangoma_boost_request_t; //#define MAX_REQ_ID ZAP_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN * ZAP_MAX_CHANNELS_PHYSICAL_SPAN @@ -395,18 +396,26 @@ static ZIO_CHANNEL_REQUEST_FUNCTION(sangoma_boost_channel_request) if (OUTBOUND_REQUESTS[r].zchan && OUTBOUND_REQUESTS[r].status != BST_READY && zap_test_flag((OUTBOUND_REQUESTS[r].zchan), ZAP_CHANNEL_INUSE)) { status = ZAP_FAIL; *zchan = NULL; - OUTBOUND_REQUESTS[event->call_setup_id].zchan = NULL; - if (zchan->extra_id) { - zchan->extra_id = 0; + if (OUTBOUND_REQUESTS[r].zchan->extra_id) { + OUTBOUND_REQUESTS[r].zchan->extra_id = 0; } - zchan->sflags = 0; - zchan->call_data = NULL; - zap_channel_done(zchan); - } + (OUTBOUND_REQUESTS[r].zchan)->sflags = 0; + (OUTBOUND_REQUESTS[r].zchan)->call_data = NULL; + zap_channel_done((OUTBOUND_REQUESTS[r].zchan)); + OUTBOUND_REQUESTS[r].zchan = NULL; + } st = OUTBOUND_REQUESTS[r].status; OUTBOUND_REQUESTS[r].status = BST_FREE; - + + if (status == ZAP_FAIL) { + if (st == BST_FAIL) { + caller_data->hangup_cause = OUTBOUND_REQUESTS[r].hangup_cause; + } else { + caller_data->hangup_cause = ZAP_CAUSE_RECOVERY_ON_TIMER_EXPIRE; + } + } + if (st == BST_FAIL) { release_request_id(r); } else if (st != BST_READY) { @@ -495,7 +504,8 @@ static void handle_call_progress(sangomabc_connection_t *mcon, sangomabc_short_e event->call_setup_id, SIGBOOST_EVENT_CALL_STOPPED, ZAP_CAUSE_DESTINATION_OUT_OF_ORDER); - OUTBOUND_REQUESTS[event->call_setup_id].status = BST_FAIL; + OUTBOUND_REQUESTS[event->call_setup_id].status = BST_FAIL; + OUTBOUND_REQUESTS[event->call_setup_id].hangup_cause = ZAP_CAUSE_DESTINATION_OUT_OF_ORDER; } /** @@ -543,6 +553,7 @@ static void handle_call_start_ack(sangomabc_connection_t *mcon, sangomabc_short_ SIGBOOST_EVENT_CALL_STOPPED, ZAP_CAUSE_DESTINATION_OUT_OF_ORDER); OUTBOUND_REQUESTS[event->call_setup_id].status = BST_FAIL; + OUTBOUND_REQUESTS[event->call_setup_id].hangup_cause = ZAP_CAUSE_DESTINATION_OUT_OF_ORDER; } @@ -633,6 +644,7 @@ static void handle_call_start_nack(zap_span_t *span, sangomabc_connection_t *mco OUTBOUND_REQUESTS[event->call_setup_id].event = *event; OUTBOUND_REQUESTS[event->call_setup_id].status = BST_FAIL; + OUTBOUND_REQUESTS[event->call_setup_id].hangup_cause = event->release_cause; return; } else { if ((zchan = find_zchan(span, event, 1))) {