From b6590855ffa3ded9e64c306a731fce31c3e262c2 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Mon, 14 Sep 2009 21:19:07 +0000 Subject: [PATCH] improve error handling in tech_init git-svn-id: http://svn.openzap.org/svn/openzap/trunk@832 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/freetdm/mod_openzap/mod_openzap.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libs/freetdm/mod_openzap/mod_openzap.c b/libs/freetdm/mod_openzap/mod_openzap.c index ddefd6e7fd..cb4e8fbae2 100644 --- a/libs/freetdm/mod_openzap/mod_openzap.c +++ b/libs/freetdm/mod_openzap/mod_openzap.c @@ -304,8 +304,15 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses switch_core_session_set_private(session, tech_pvt); tech_pvt->session = session; - zap_channel_command(zchan, ZAP_COMMAND_GET_INTERVAL, &interval); - zap_channel_command(zchan, ZAP_COMMAND_GET_CODEC, &codec); + if (ZAP_SUCCESS != zap_channel_command(zchan, ZAP_COMMAND_GET_INTERVAL, &interval)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to retrieve channel interval.\n"); + return SWITCH_STATUS_GENERR; + } + + if (ZAP_SUCCESS != zap_channel_command(zchan, ZAP_COMMAND_GET_CODEC, &codec)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to retrieve channel codec.\n"); + return SWITCH_STATUS_GENERR; + } switch(codec) { case ZAP_CODEC_ULAW: @@ -324,7 +331,10 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses } break; default: - abort(); + { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid codec value retrieved from channel, codec value: %d\n", codec); + return SWITCH_STATUS_GENERR; + } } @@ -2902,5 +2912,5 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_openzap_shutdown) * c-basic-offset:4 * End: * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 */