From 2070e9d05b74c8c413fccdd033516609d4174930 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 29 Aug 2008 20:41:17 +0000 Subject: [PATCH] doh git-svn-id: http://svn.openzap.org/svn/openzap/trunk@522 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/freetdm/mod_openzap/mod_openzap.c | 15 +++++----- libs/freetdm/src/include/zap_types.h | 2 ++ .../src/ozmod/ozmod_analog/ozmod_analog.c | 1 - .../ozmod/ozmod_ss7_boost/ozmod_ss7_boost.c | 3 +- libs/freetdm/src/testanalog.c | 3 +- libs/freetdm/src/testboost.c | 4 +-- libs/freetdm/src/testisdn.c | 16 ++-------- libs/freetdm/src/zap_io.c | 29 +++++++++++++------ 8 files changed, 38 insertions(+), 35 deletions(-) diff --git a/libs/freetdm/mod_openzap/mod_openzap.c b/libs/freetdm/mod_openzap/mod_openzap.c index ae9133bf1d..b93a5abc55 100644 --- a/libs/freetdm/mod_openzap/mod_openzap.c +++ b/libs/freetdm/mod_openzap/mod_openzap.c @@ -1538,6 +1538,7 @@ static switch_status_t load_config(void) if (!id) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing required param 'id'\n"); + continue; } span_id = atoi(id); @@ -1562,8 +1563,8 @@ static switch_status_t load_config(void) if (zap_configure_span("analog", span, on_analog_signal, "tonemap", tonegroup, "digit_timeout", &to, - "max_dialstr", &max - ) != ZAP_SUCCESS) { + "max_dialstr", &max, + TAG_END) != ZAP_SUCCESS) { zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d\n", span_id); continue; } @@ -1640,8 +1641,8 @@ static switch_status_t load_config(void) if (zap_configure_span("isdn", span, on_clear_channel_signal, "mode", mode, - "dialect", dialect - ) != ZAP_SUCCESS) { + "dialect", dialect, + TAG_END) != ZAP_SUCCESS) { zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d mode: %d dialect: %d error: %s\n", span_id, mode, dialect, span->last_error); continue; } @@ -1689,7 +1690,7 @@ static switch_status_t load_config(void) } } - if (!(id && local_ip && local_port && remote_ip && remote_port) ) { + if (!id) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing required param\n"); continue; } @@ -1709,8 +1710,8 @@ static switch_status_t load_config(void) "local_ip", local_ip, "local_port", &local_port, "remote_ip", remote_ip, - "remote_port", &remote_port - ) != ZAP_SUCCESS) { + "remote_port", &remote_port, + TAG_END) != ZAP_SUCCESS) { zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d error: %s\n", span_id, span->last_error); continue; } diff --git a/libs/freetdm/src/include/zap_types.h b/libs/freetdm/src/include/zap_types.h index 9c14686f8c..3c04b8db8d 100644 --- a/libs/freetdm/src/include/zap_types.h +++ b/libs/freetdm/src/include/zap_types.h @@ -58,6 +58,8 @@ typedef ssize_t zap_ssize_t; typedef int zap_filehandle_t; #endif +#define TAG_END NULL + typedef size_t zap_size_t; struct zap_io_interface; diff --git a/libs/freetdm/src/ozmod/ozmod_analog/ozmod_analog.c b/libs/freetdm/src/ozmod/ozmod_analog/ozmod_analog.c index fe438c2244..3d04425880 100644 --- a/libs/freetdm/src/ozmod/ozmod_analog/ozmod_analog.c +++ b/libs/freetdm/src/ozmod/ozmod_analog/ozmod_analog.c @@ -107,7 +107,6 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_configure_span) memset(analog_data, 0, sizeof(*analog_data)); assert(analog_data != NULL); - while(var = va_arg(ap, char *)) { if (!strcasecmp(var, "tonemap")) { if (!(val = va_arg(ap, char *))) { diff --git a/libs/freetdm/src/ozmod/ozmod_ss7_boost/ozmod_ss7_boost.c b/libs/freetdm/src/ozmod/ozmod_ss7_boost/ozmod_ss7_boost.c index 64cad3c02d..14086a5154 100644 --- a/libs/freetdm/src/ozmod/ozmod_ss7_boost/ozmod_ss7_boost.c +++ b/libs/freetdm/src/ozmod/ozmod_ss7_boost/ozmod_ss7_boost.c @@ -1122,6 +1122,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_ss7_boost_configure_span) if (!local_ip && local_port && remote_ip && remote_port && sig_cb) { + zap_set_string(span->last_error, "missing params"); return ZAP_FAIL; } @@ -1147,7 +1148,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_ss7_boost_configure_span) zap_module_t zap_module = { - "analog", + "ss7_boost", NULL, NULL, zap_ss7_boost_init, diff --git a/libs/freetdm/src/testanalog.c b/libs/freetdm/src/testanalog.c index 813605decc..dd91c639d9 100644 --- a/libs/freetdm/src/testanalog.c +++ b/libs/freetdm/src/testanalog.c @@ -98,7 +98,8 @@ int main(int argc, char *argv[]) if (zap_configure_span("analog", span, on_signal, "tonemap", "te", "digit_timeout", &digit_timeout, - "max_dialstr", &max_dialstr + "max_dialstr", &max_dialstr, + TAG_END ) == ZAP_SUCCESS) { zap_log(ZAP_LOG_ERROR, "Error configuring OpenZAP span\n"); goto done; diff --git a/libs/freetdm/src/testboost.c b/libs/freetdm/src/testboost.c index c27636efab..e585fcbb1d 100644 --- a/libs/freetdm/src/testboost.c +++ b/libs/freetdm/src/testboost.c @@ -43,8 +43,8 @@ int main(int argc, char *argv[]) "local_ip", "127.0.0.65", "local_port", &local_port, "remote_ip", "127.0.0.66", - "remote_port", &remote_port - ) == ZAP_SUCCESS) { + "remote_port", &remote_port, + TAG_END) == ZAP_SUCCESS) { zap_span_start(span); } else { fprintf(stderr, "Error starting SS7_BOOST\n"); diff --git a/libs/freetdm/src/testisdn.c b/libs/freetdm/src/testisdn.c index 29bf4c952b..7606d4bb74 100644 --- a/libs/freetdm/src/testisdn.c +++ b/libs/freetdm/src/testisdn.c @@ -38,27 +38,15 @@ int main(int argc, char *argv[]) goto done; } - -#if 1 - if (zap_configure_span("isdn", span, on_signal, "mode", "te", - "dialect", "national" - ) == ZAP_SUCCESS) { + "dialect", "national", + TAG_END) == ZAP_SUCCESS) { zap_span_start(span); } else { fprintf(stderr, "Error starting ISDN D-Channel\n"); goto done; } -#else - if (zap_isdn_configure_span(span, Q931_TE, Q931_Dialect_National, 0, on_signal) == ZAP_SUCCESS) { - zap_isdn_start(span); - } else { - fprintf(stderr, "Error starting ISDN D-Channel\n"); - goto done; - } - -#endif signal(SIGINT, handle_SIGINT); R = 1; diff --git a/libs/freetdm/src/zap_io.c b/libs/freetdm/src/zap_io.c index 7eb6bda296..1619493294 100644 --- a/libs/freetdm/src/zap_io.c +++ b/libs/freetdm/src/zap_io.c @@ -2135,13 +2135,13 @@ int zap_load_modules(void) if (!(lib = zap_dso_open(path, &err))) { zap_log(ZAP_LOG_ERROR, "Error loading %s [%s]\n", path, err); - free(err); + zap_safe_free(err); continue; } if (!(mod = (zap_module_t *) zap_dso_func_sym(lib, "zap_module", &err))) { zap_log(ZAP_LOG_ERROR, "Error loading %s [%s]\n", path, err); - free(err); + zap_safe_free(err); continue; } @@ -2149,20 +2149,24 @@ int zap_load_modules(void) zap_io_interface_t *interface; if (mod->io_load(&interface) != ZAP_SUCCESS || !interface) { - zap_log(ZAP_LOG_ERROR, "Error loading %s [%s]\n", path, err); + zap_log(ZAP_LOG_ERROR, "Error loading %s\n", path); } else { zap_log(ZAP_LOG_INFO, "Loading IO from %s\n", path); zap_mutex_lock(globals.mutex); - hashtable_insert(globals.interface_hash, (void *)interface->name, interface); - process_module_config(interface); + if (hashtable_search(globals.interface_hash, (void *)interface->name)) { + zap_log(ZAP_LOG_ERROR, "Interface %s already loaded!\n", interface->name); + } else { + hashtable_insert(globals.interface_hash, (void *)interface->name, interface); + process_module_config(interface); + x++; + } zap_mutex_unlock(globals.mutex); - x++; } } if (mod->sig_load) { if (mod->sig_load() != ZAP_SUCCESS) { - zap_log(ZAP_LOG_ERROR, "Error loading %s [%s]\n", path, err); + zap_log(ZAP_LOG_ERROR, "Error loading %s\n", path); } else { zap_log(ZAP_LOG_INFO, "Loading SIG from %s\n", path); x++; @@ -2180,8 +2184,15 @@ int zap_load_modules(void) zap_set_string(mod->name, p); } - hashtable_insert(globals.module_hash, (void *)mod->name, mod); - count++; + zap_mutex_lock(globals.mutex); + if (hashtable_search(globals.module_hash, (void *)mod->name)) { + zap_log(ZAP_LOG_ERROR, "Module %s already loaded!\n", mod->name); + zap_dso_destroy(&lib); + } else { + hashtable_insert(globals.module_hash, (void *)mod->name, mod); + count++; + } + zap_mutex_unlock(globals.mutex); } else { zap_log(ZAP_LOG_ERROR, "Unloading %s\n", path); zap_dso_destroy(&lib);