diff --git a/libs/openzap/mod_openzap/mod_openzap.c b/libs/openzap/mod_openzap/mod_openzap.c index 3de436c24f..437e3204c8 100644 --- a/libs/openzap/mod_openzap/mod_openzap.c +++ b/libs/openzap/mod_openzap/mod_openzap.c @@ -752,21 +752,21 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s tech_pvt = (private_t *) switch_core_session_get_private(session); assert(tech_pvt != NULL); - switch_mutex_lock(tech_pvt->flag_mutex); - switch (tech_pvt->zchan->type) { case ZAP_CHAN_TYPE_FXS: status = channel_receive_message_fxs(session, msg); + break; case ZAP_CHAN_TYPE_FXO: status = channel_receive_message_fxo(session, msg); + break; case ZAP_CHAN_TYPE_B: status = channel_receive_message_b(session, msg); + break; default: status = SWITCH_STATUS_FALSE; + break; } - switch_mutex_unlock(tech_pvt->flag_mutex); - return status; } diff --git a/libs/openzap/src/zap_analog.c b/libs/openzap/src/zap_analog.c index ce01ffaa68..63e360df10 100644 --- a/libs/openzap/src/zap_analog.c +++ b/libs/openzap/src/zap_analog.c @@ -284,7 +284,8 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj) zap_channel_command(zchan, ZAP_COMMAND_GENERATE_RING_OFF, NULL); } - if (zap_test_flag(zchan, ZAP_CHANNEL_OFFHOOK) && zchan->last_state >= ZAP_CHANNEL_STATE_IDLE) { + if (zap_test_flag(zchan, ZAP_CHANNEL_OFFHOOK) && + (zchan->last_state == ZAP_CHANNEL_STATE_RING || zchan->last_state >= ZAP_CHANNEL_STATE_IDLE)) { zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_BUSY); } else { zchan->caller_data.hangup_cause = ZAP_CAUSE_NORMAL_CLEARING;