diff --git a/libs/freetdm/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c b/libs/freetdm/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c index 9ae91de014..32af0a5c48 100644 --- a/libs/freetdm/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c +++ b/libs/freetdm/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c @@ -1157,7 +1157,9 @@ static zap_status_t zap_boost_connection_open(zap_span_t *span) { zap_sangoma_boost_data_t *sangoma_boost_data = span->signal_data; if (sangoma_boost_data->sigmod) { - return sangoma_boost_data->sigmod->start_span(span); + if (sangoma_boost_data->sigmod->start_span(span) != ZAP_SUCCESS) { + return ZAP_FAIL; + } } sangoma_boost_data->pcon = sangoma_boost_data->mcon; @@ -1338,9 +1340,10 @@ static void *zap_sangoma_boost_run(zap_thread_t *me, void *obj) zap_log(ZAP_LOG_CRIT, "Boost event processing Error!\n"); end: - - sangomabc_connection_close(&sangoma_boost_data->mcon); - sangomabc_connection_close(&sangoma_boost_data->pcon); + if (!sangoma_boost_data->sigmod) { + sangomabc_connection_close(&sangoma_boost_data->mcon); + sangomabc_connection_close(&sangoma_boost_data->pcon); + } zap_clear_flag(sangoma_boost_data, ZAP_SANGOMA_BOOST_RUNNING); @@ -1371,17 +1374,14 @@ static ZIO_SIG_UNLOAD_FUNCTION(zap_sangoma_boost_destroy) boost_sigmod_interface_t *sigmod = NULL; const void *key = NULL; void *val = NULL; + zap_dso_lib_t lib; for (i = hashtable_first(g_boost_modules_hash); i; i = hashtable_next(i)) { hashtable_this(i, &key, NULL, &val); if (key && val) { sigmod = val; - if (sigmod->on_unload() != ZAP_SUCCESS) { - zap_log(ZAP_LOG_ERROR, "Failed to unload boost signaling module object\n"); - /* hope for the best */ - } else { - zap_dso_destroy(sigmod->pvt); - } + lib = sigmod->pvt; + zap_dso_destroy(&lib); } } @@ -1581,7 +1581,7 @@ static ZIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(zap_sangoma_boost_configure_span) if (hash_locked) \ zap_mutex_unlock(g_boost_modules_mutex); \ if (lib) \ - zap_dso_destroy(lib); \ + zap_dso_destroy(&lib); \ return retstatus; boost_sigmod_interface_t *sigmod_iface = NULL; @@ -1646,10 +1646,6 @@ static ZIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(zap_sangoma_boost_configure_span) FAIL_CONFIG_RETURN(ZAP_FAIL); } - if (sigmod_iface->on_load() != ZAP_SUCCESS) { - zap_log(ZAP_LOG_ERROR, "Failed to load Sangoma boost signaling module interface '%s': on_load method failed\n", path); - FAIL_CONFIG_RETURN(ZAP_FAIL); - } sigmod_iface->pvt = lib; sigmod_iface->set_write_msg_cb(zap_boost_write_msg); sigmod_iface->set_sig_status_cb(zap_boost_sig_status_change); diff --git a/libs/freetdm/src/ozmod/ozmod_sangoma_boost/sangoma_boost_client.c b/libs/freetdm/src/ozmod/ozmod_sangoma_boost/sangoma_boost_client.c index cf421aa4fa..f2021d5392 100644 --- a/libs/freetdm/src/ozmod/ozmod_sangoma_boost/sangoma_boost_client.c +++ b/libs/freetdm/src/ozmod/ozmod_sangoma_boost/sangoma_boost_client.c @@ -173,7 +173,6 @@ static int create_conn_socket(sangomabc_connection_t *mcon, char *local_ip, int } } - zap_mutex_create(&mcon->mutex); return mcon->socket; } @@ -201,8 +200,9 @@ int sangomabc_connection_close(sangomabc_connection_t *mcon) int sangomabc_connection_open(sangomabc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port) { + zap_mutex_create(&mcon->mutex); if (mcon->sigmod) { - zap_log(ZAP_LOG_WARNING, "I should not be called on a sigmod-managed connection!\n"); + /*value of mcon->socket will be ignored in sigmod mode */ return 0; } create_conn_socket(mcon, local_ip, local_port, ip, port); @@ -474,22 +474,24 @@ int __sangomabc_connection_writep(sangomabc_connection_t *mcon, sangomabc_event_ int err; int event_size=sizeof(sangomabc_event_t); - if (!event || mcon->socket < 0 || !mcon->mutex) { - zap_log(file, func, line, ZAP_LOG_LEVEL_CRIT, "Critical Error: No Event Device\n"); - return -EINVAL; - abort(); + if (!mcon->sigmod) { + if (!event || mcon->socket < 0 || !mcon->mutex) { + zap_log(file, func, line, ZAP_LOG_LEVEL_CRIT, "Critical Error: No Event Device\n"); + return -EINVAL; + abort(); + } } - + if (!boost_full_event(event->event_id)) { event_size=sizeof(sangomabc_short_event_t); } zap_mutex_lock(mcon->mutex); - event->version = SIGBOOST_VERSION; + event->version = SIGBOOST_VERSION; if (mcon->sigmod) { mcon->sigmod->write_msg(mcon->span, event, event_size); - err = event_size; - return -1; + err = event_size; + } else { err = sendto(mcon->socket, event, event_size, 0, (struct sockaddr *) &mcon->remote_addr, sizeof(mcon->remote_addr)); }