diff --git a/configure.in b/configure.in index 36584fb262..d186eebc94 100644 --- a/configure.in +++ b/configure.in @@ -418,32 +418,45 @@ SWITCH_AM_CFLAGS="$LIBUUID_CFLAGS $SWITCH_AM_CFLAGS" AC_ARG_ENABLE(core-pgsql-support, [AS_HELP_STRING([--enable-core-pgsql-support], [Compile with PGSQL Support])],,[enable_core_pgsql_support="no"]) +AC_ARG_ENABLE(core-pgsql-pkgconfig, + [AS_HELP_STRING([--disable-core-pgsql-pkgconfig], [Use pg_config to get PGQSL build options])],[enable_core_pgsql_pkgconfig="$enableval"],[enable_core_pgsql_pkgconfig="yes"]) if test x"$enable_core_pgsql_support" = x"yes" ; then - -AC_PATH_PROG([PG_CONFIG], [pg_config], [no]) -if test "$PG_CONFIG" != "no"; then - AC_MSG_CHECKING([for PostgreSQL libraries]) - POSTGRESQL_CXXFLAGS="`$PG_CONFIG --cppflags` -I`$PG_CONFIG --includedir`" - POSTGRESQL_LDFLAGS="`$PG_CONFIG --ldflags|sed 's/ -Wl,--as-needed//g'` -L`$PG_CONFIG --libdir` -lpq" - POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'` - POSTGRESQL_MAJOR_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL ([0-9]+).[0-9]+.?[0-9]+?#\1#'` - POSTGRESQL_MINOR_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL [0-9]+.([0-9]+).?[0-9]+?#\1#'` - POSTGRESQL_PATCH_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL [0-9]+.[0-9]+.?([0-9]+)?#\1#'` - AC_DEFINE([SWITCH_HAVE_PGSQL], [1], [Define to 1 if PostgreSQL libraries are available]) - AC_DEFINE_UNQUOTED([POSTGRESQL_VERSION], "${POSTGRESQL_VERSION}", [Specifies the version of PostgreSQL we are linking against]) - AC_DEFINE_UNQUOTED([POSTGRESQL_MAJOR_VERSION], ${POSTGRESQL_MAJOR_VERSION}, [Specifies the version of PostgreSQL we are linking against]) - AC_DEFINE_UNQUOTED([POSTGRESQL_MINOR_VERSION], ${POSTGRESQL_MINOR_VERSION}, [Specifies the version of PostgreSQL we are linking against]) - AC_DEFINE_UNQUOTED([POSTGRESQL_PATCH_VERSION], ${POSTGRESQL_PATCH_VERSION}, [Specifies the version of PostgreSQL we are linking against]) - AC_CHECK_LIB([pq], [PQgetvalue],, AC_MSG_ERROR([no usable libpq; please install PostgreSQL devel package or equivalent])) - AC_MSG_RESULT([yes]) - SWITCH_AM_CXXFLAGS="$POSTGRESQL_CXXFLAGS $SWITCH_AM_CXXFLAGS" - SWITCH_AM_LDFLAGS="$POSTGRESQL_LDFLAGS $SWITCH_AM_LDFLAGS" -else - AC_MSG_RESULT([no]) - AC_MSG_FAILURE([Unabled to find pg_config in PATH. Is PostgreSQL installed?]) -fi - + AC_PATH_PROG([PG_CONFIG], [pg_config], [no]) + AC_PATH_PROG([PKG_CONFIG], [pkg-config], [no]) + if test "$PG_CONFIG" = "no"; then + AC_MSG_RESULT([no]) + AC_MSG_FAILURE([Unabled to find pg_config in PATH. Is PostgreSQL installed?]) + else + if test "$PKG_CONFIG" = "no" \ + || test x"$enable_core_pgsql_pkgconfig" = x"no" \ + || ! pkg-config libpq; then + AC_MSG_CHECKING([for PostgreSQL libraries]) + POSTGRESQL_CXXFLAGS="`$PG_CONFIG --cppflags` -I`$PG_CONFIG --includedir`" + POSTGRESQL_LDFLAGS="`$PG_CONFIG --ldflags|sed 's/ -Wl,--as-needed//g'` -L`$PG_CONFIG --libdir` -lpq" + POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'` + POSTGRESQL_MAJOR_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL ([0-9]+).[0-9]+.?[0-9]+?#\1#'` + POSTGRESQL_MINOR_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL [0-9]+.([0-9]+).?[0-9]+?#\1#'` + POSTGRESQL_PATCH_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL [0-9]+.[0-9]+.?([0-9]+)?#\1#'` + else + AC_MSG_CHECKING([for PostgreSQL libraries]) + POSTGRESQL_CXXFLAGS="`$PKG_CONFIG --cflags libpq`" + POSTGRESQL_LDFLAGS="`$PKG_CONFIG --libs libpq`" + POSTGRESQL_VERSION="`$PKG_CONFIG --modversion libpq`" + POSTGRESQL_MAJOR_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f1`" + POSTGRESQL_MINOR_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f2`" + POSTGRESQL_PATCH_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f3`" + fi + AC_DEFINE([SWITCH_HAVE_PGSQL], [1], [Define to 1 if PostgreSQL libraries are available]) + AC_DEFINE_UNQUOTED([POSTGRESQL_VERSION], "${POSTGRESQL_VERSION}", [Specifies the version of PostgreSQL we are linking against]) + AC_DEFINE_UNQUOTED([POSTGRESQL_MAJOR_VERSION], ${POSTGRESQL_MAJOR_VERSION}, [Specifies the version of PostgreSQL we are linking against]) + AC_DEFINE_UNQUOTED([POSTGRESQL_MINOR_VERSION], ${POSTGRESQL_MINOR_VERSION}, [Specifies the version of PostgreSQL we are linking against]) + AC_DEFINE_UNQUOTED([POSTGRESQL_PATCH_VERSION], ${POSTGRESQL_PATCH_VERSION}, [Specifies the version of PostgreSQL we are linking against]) + AC_CHECK_LIB([pq], [PQgetvalue],, AC_MSG_ERROR([no usable libpq; please install PostgreSQL devel package or equivalent])) + AC_MSG_RESULT([yes]) + SWITCH_AM_CXXFLAGS="$POSTGRESQL_CXXFLAGS $SWITCH_AM_CXXFLAGS" + SWITCH_AM_LDFLAGS="$POSTGRESQL_LDFLAGS $SWITCH_AM_LDFLAGS" + fi fi AC_ARG_ENABLE(deprecated-core-db-events, diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index 241cdefa22..5dc89e0a24 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Mon Oct 21 20:11:13 CDT 2013 +Tue Oct 22 16:25:25 CDT 2013 diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport.c index ccffb5e007..aa257f79f8 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport.c @@ -903,7 +903,6 @@ tport_t *tport_alloc_secondary(tport_primary_t *pri, pri->pri_params->tpp_tos); } else { - su_close(socket); *return_reason = "malloc"; } @@ -2620,6 +2619,8 @@ int tport_accept(tport_primary_t *pri, int events) SU_DEBUG_3(("%s(%p): incoming secondary on "TPN_FORMAT " failed. reason = %s\n", __func__, (void *)pri, TPN_ARGS(pri->pri_primary->tp_name), reason)); + shutdown(s, 2); + su_close(s); return 0; } else { diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.h b/libs/sofia-sip/libsofia-sip-ua/tport/ws.h index 992998be48..7b02b47966 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.h +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.h @@ -26,6 +26,8 @@ #include #ifdef _MSC_VER +#define strncasecmp _strnicmp +#define snprintf _snprintf #ifdef _WIN64 #define WS_SSIZE_T __int64 #elif _MSC_VER >= 1400 @@ -33,7 +35,7 @@ #else #define WS_SSIZE_T __int32 #endif -typedef WS_SSIZE_T ssize_t +typedef WS_SSIZE_T ssize_t; #endif diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 886930f096..3c6bc7a169 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -576,6 +576,8 @@ static struct { switch_hash_t *caller_orig_hash; switch_hash_t *consumer_orig_hash; switch_hash_t *bridge_hash; + switch_hash_t *use_hash; + switch_mutex_t *use_mutex; switch_mutex_t *caller_orig_mutex; switch_mutex_t *consumer_orig_mutex; switch_mutex_t *bridge_mutex; @@ -604,6 +606,66 @@ static struct { +static int fifo_dec_use_count(const char *outbound_id) +{ + int r = 0, *count; + + + switch_mutex_lock(globals.use_mutex); + if ((count = (int *) switch_core_hash_find(globals.use_hash, outbound_id))) { + if (*count > 0) { + r = --(*count); + } + } + switch_mutex_unlock(globals.use_mutex); + + return r; +} + +static int fifo_get_use_count(const char *outbound_id) +{ + int r = 0, *count; + + switch_mutex_lock(globals.use_mutex); + if ((count = (int *) switch_core_hash_find(globals.use_hash, outbound_id))) { + r = *count; + } + switch_mutex_unlock(globals.use_mutex); + + return r; +} + + +static int fifo_inc_use_count(const char *outbound_id) +{ + int r = 0, *count; + + switch_mutex_lock(globals.use_mutex); + if (!(count = (int *) switch_core_hash_find(globals.use_hash, outbound_id))) { + count = switch_core_alloc(globals.pool, sizeof(int)); + switch_core_hash_insert(globals.use_hash, outbound_id, count); + } + + r = ++(*count); + + switch_mutex_unlock(globals.use_mutex); + + return r; +} + +static void fifo_init_use_count(void) +{ + switch_mutex_lock(globals.use_mutex); + if (globals.use_hash) { + switch_core_hash_destroy(&globals.use_hash); + } + switch_core_hash_init(&globals.use_hash, globals.pool); + switch_mutex_unlock(globals.use_mutex); +} + + + + static int check_caller_outbound_call(const char *key) { int x = 0; @@ -961,10 +1023,16 @@ static void do_unbridge(switch_core_session_t *consumer_session, switch_core_ses const char *epoch_start_a = NULL; char *sql; switch_event_t *event; + const char *outbound_id = NULL; + int use_count = 0; switch_channel_clear_app_flag_key(FIFO_APP_KEY, consumer_channel, FIFO_APP_BRIDGE_TAG); switch_channel_set_variable(consumer_channel, "fifo_bridged", NULL); + if ((outbound_id = switch_channel_get_variable(consumer_channel, "fifo_outbound_uuid"))) { + use_count = fifo_get_use_count(outbound_id); + } + ts = switch_micro_time_now(); switch_time_exp_lt(&tm, ts); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); @@ -999,6 +1067,10 @@ static void do_unbridge(switch_core_session_t *consumer_session, switch_core_ses switch_channel_event_set_data(consumer_channel, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", MANUAL_QUEUE_NAME); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "bridge-consumer-stop"); + if (use_count) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Outbound-ID", outbound_id); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Use-Count", "%d", use_count); + } switch_event_fire(&event); } @@ -1072,7 +1144,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_ switch_time_t ts; switch_time_exp_t tm; switch_size_t retsize; - const char *ced_name, *ced_number, *cid_name, *cid_number; + const char *ced_name, *ced_number, *cid_name, *cid_number, *outbound_id; if (switch_channel_test_app_flag_key(FIFO_APP_KEY, consumer_channel, FIFO_APP_BRIDGE_TAG)) { goto end; @@ -1083,6 +1155,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_ switch_channel_set_variable(consumer_channel, "fifo_bridged", "true"); switch_channel_set_variable(consumer_channel, "fifo_manual_bridge", "true"); switch_channel_set_variable(consumer_channel, "fifo_role", "consumer"); + outbound_id = switch_channel_get_variable(consumer_channel, "fifo_outbound_uuid"); if (caller_channel) { switch_channel_set_variable(caller_channel, "fifo_role", "caller"); @@ -1118,6 +1191,10 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "bridge-consumer-start"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Caller-CID-Name", ced_name); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Caller-CID-Number", ced_number); + if (outbound_id) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Outbound-ID", outbound_id); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Use-Count", "%d", fifo_get_use_count(outbound_id)); + } switch_event_fire(&event); } @@ -2144,7 +2221,7 @@ SWITCH_STANDARD_API(fifo_add_outbound_function) static void dec_use_count(switch_core_session_t *session, switch_bool_t send_event) { char *sql; - const char *outbound_id; + const char *outbound_id = NULL; switch_event_t *event; long now = (long) switch_epoch_time_now(NULL); switch_channel_t *channel = switch_core_session_get_channel(session); @@ -2162,6 +2239,7 @@ static void dec_use_count(switch_core_session_t *session, switch_bool_t send_eve sql = switch_mprintf("update fifo_outbound set use_count=use_count-1, stop_time=%ld, next_avail=%ld + lag + 1 where use_count > 0 and uuid='%q'", now, now, outbound_id); fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); + fifo_dec_use_count(outbound_id); } if (send_event) { @@ -2169,6 +2247,10 @@ static void dec_use_count(switch_core_session_t *session, switch_bool_t send_eve switch_channel_event_set_data(channel, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", MANUAL_QUEUE_NAME); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "channel-consumer-stop"); + if (outbound_id) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Outbound-ID", outbound_id); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Use-Count", "%d", fifo_get_use_count(outbound_id)); + } switch_event_fire(&event); } } @@ -2229,7 +2311,7 @@ SWITCH_STANDARD_APP(fifo_track_call_function) sql = switch_mprintf("update fifo_outbound set stop_time=0,start_time=%ld,outbound_fail_count=0,use_count=use_count+1,%s=%s+1,%s=%s+1 where uuid='%q'", (long) switch_epoch_time_now(NULL), col1, col1, col2, col2, data); fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); - + fifo_inc_use_count(data); if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) { cid_name = switch_channel_get_variable(channel, "destination_number"); @@ -2647,6 +2729,7 @@ SWITCH_STANDARD_APP(fifo_function) const char *url = NULL; const char *caller_uuid = NULL; const char *outbound_id = switch_channel_get_variable(channel, "fifo_outbound_uuid"); + //const char *track_use_count = switch_channel_get_variable(channel, "fifo_track_use_count"); //int do_track = switch_true(track_use_count); @@ -3051,18 +3134,6 @@ SWITCH_STANDARD_APP(fifo_function) switch_process_import(session, other_channel, "fifo_caller_consumer_import", switch_channel_get_variable(channel, "fifo_import_prefix")); switch_process_import(other_session, channel, "fifo_consumer_caller_import", switch_channel_get_variable(other_channel, "fifo_import_prefix")); - if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { - switch_channel_event_set_data(channel, event); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "bridge-consumer-start"); - switch_event_fire(&event); - } - if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { - switch_channel_event_set_data(other_channel, event); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "bridge-caller-start"); - switch_event_fire(&event); - } if (outbound_id) { cancel_consumer_outbound_call(outbound_id, SWITCH_CAUSE_ORIGINATOR_CANCEL); @@ -3073,8 +3144,29 @@ SWITCH_STANDARD_APP(fifo_function) fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); + fifo_inc_use_count(outbound_id); + } + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "bridge-consumer-start"); + if (outbound_id) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Outbound-ID", outbound_id); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Use-Count", "%d", fifo_get_use_count(outbound_id)); + } + + switch_event_fire(&event); + } + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(other_channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "bridge-caller-start"); + switch_event_fire(&event); + } + + add_bridge_call(switch_core_session_get_uuid(other_session)); add_bridge_call(switch_core_session_get_uuid(session)); @@ -3125,6 +3217,7 @@ SWITCH_STANDARD_APP(fifo_function) fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); del_bridge_call(outbound_id); + fifo_dec_use_count(outbound_id); } @@ -3136,6 +3229,10 @@ SWITCH_STANDARD_APP(fifo_function) switch_channel_event_set_data(channel, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "bridge-consumer-stop"); + if (outbound_id) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Outbound-ID", outbound_id); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Use-Count", "%d", fifo_get_use_count(outbound_id)); + } switch_event_fire(&event); } if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { @@ -4129,6 +4226,7 @@ static switch_status_t load_config(int reload, int del_all) if (!reload) { char *sql= "update fifo_outbound set start_time=0,stop_time=0,ring_count=0,use_count=0,outbound_call_count=0,outbound_fail_count=0 where static=0"; fifo_execute_sql_queued(&sql, SWITCH_FALSE, SWITCH_TRUE); + fifo_init_use_count(); } if (reload) { @@ -4547,11 +4645,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_fifo_load) switch_core_hash_init(&globals.caller_orig_hash, globals.pool); switch_core_hash_init(&globals.consumer_orig_hash, globals.pool); switch_core_hash_init(&globals.bridge_hash, globals.pool); + switch_core_hash_init(&globals.use_hash, globals.pool); switch_mutex_init(&globals.caller_orig_mutex, SWITCH_MUTEX_NESTED, globals.pool); switch_mutex_init(&globals.consumer_orig_mutex, SWITCH_MUTEX_NESTED, globals.pool); switch_mutex_init(&globals.bridge_mutex, SWITCH_MUTEX_NESTED, globals.pool); switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool); + switch_mutex_init(&globals.use_mutex, SWITCH_MUTEX_NESTED, globals.pool); switch_mutex_init(&globals.sql_mutex, SWITCH_MUTEX_NESTED, globals.pool); globals.running = 1; diff --git a/src/mod/endpoints/mod_loopback/mod_loopback.c b/src/mod/endpoints/mod_loopback/mod_loopback.c index ee354ad90b..aea8032433 100644 --- a/src/mod/endpoints/mod_loopback/mod_loopback.c +++ b/src/mod/endpoints/mod_loopback/mod_loopback.c @@ -488,7 +488,6 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session) { switch_channel_t *channel = NULL; loopback_private_t *tech_pvt = NULL; - void *pop; switch_event_t *vars; channel = switch_core_session_get_channel(session); @@ -516,10 +515,7 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session) switch_frame_free(&tech_pvt->write_frame); } - while (switch_queue_trypop(tech_pvt->frame_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) { - switch_frame_t *frame = (switch_frame_t *) pop; - switch_frame_free(&frame); - } + clear_queue(tech_pvt); } diff --git a/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c b/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c index a268e8d158..4e6083086a 100644 --- a/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c +++ b/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c @@ -290,6 +290,26 @@ static void do_rotate_all() } +static void do_teardown() +{ + switch_hash_index_t *hi; + void *val; + cdr_fd_t *fd; + switch_mutex_lock(globals.mutex); + for (hi = switch_hash_first(NULL, globals.fd_hash); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, NULL, NULL, &val); + fd = (cdr_fd_t *) val; + switch_mutex_lock(fd->mutex); + if (fd->fd > -1) { + close(fd->fd); + fd->fd = -1; + } + switch_mutex_unlock(fd->mutex); + } + switch_mutex_unlock(globals.mutex); +} + + static void event_handler(switch_event_t *event) { const char *sig = switch_event_get_header(event, "Trapped-Signal"); @@ -445,6 +465,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_csv_shutdown) switch_event_unbind_callback(event_handler); switch_core_remove_state_handler(&state_handlers); + do_teardown(); + switch_core_hash_destroy(&globals.fd_hash); + switch_core_hash_destroy(&globals.template_hash); return SWITCH_STATUS_SUCCESS; } diff --git a/src/switch_core_codec.c b/src/switch_core_codec.c index bd3b521a98..db0db33cd5 100644 --- a/src/switch_core_codec.c +++ b/src/switch_core_codec.c @@ -655,7 +655,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_init_with_bitrate(switch_codec /* If no specific codec interval is requested opt for 20ms above all else because lots of stuff assumes it */ if (!ms) { for (iptr = codec_interface->implementations; iptr; iptr = iptr->next) { - if ((!rate || rate == iptr->samples_per_second) && (!bitrate || bitrate == (uint32_t)iptr->bits_per_second) && + uint32_t crate = !strcasecmp(codec_name, "g722") ? iptr->samples_per_second : iptr->actual_samples_per_second; + if ((!rate || rate == crate) && (!bitrate || bitrate == (uint32_t)iptr->bits_per_second) && (20 == (iptr->microseconds_per_packet / 1000)) && (!channels || channels == iptr->number_of_channels)) { implementation = iptr; goto found; @@ -665,7 +666,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_init_with_bitrate(switch_codec /* Either looking for a specific interval or there was no interval specified and there wasn't one @20ms available */ for (iptr = codec_interface->implementations; iptr; iptr = iptr->next) { - if ((!rate || rate == iptr->samples_per_second) && (!bitrate || bitrate == (uint32_t)iptr->bits_per_second) && + uint32_t crate = !strcasecmp(codec_name, "g722") ? iptr->samples_per_second : iptr->actual_samples_per_second; + if ((!rate || rate == crate) && (!bitrate || bitrate == (uint32_t)iptr->bits_per_second) && (!ms || ms == (iptr->microseconds_per_packet / 1000)) && (!channels || channels == iptr->number_of_channels)) { implementation = iptr; break; diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 7dd02df818..0b4d8b9ede 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -510,8 +510,6 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10, "Create Cached DB handle %s [%s] %s:%d\n", new_dbh->name, switch_cache_db_type_name(type), file, line); - new_dbh = create_handle(type); - if (db) { new_dbh->native_handle.core_db_dbh = db; } else if (odbc_dbh) { diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index c9fdda1da7..df1e351bba 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -188,10 +188,18 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable } if (load_interface) { for (impl = ptr->implementations; impl; impl = impl->next) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, - "Adding Codec %s %d %s %dhz %dms %dbps\n", - impl->iananame, impl->ianacode, - ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_packet / 1000, impl->bits_per_second); + if (impl->bits_per_second) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, + "Adding Codec %s %d %s %dhz %dms %dbps\n", + impl->iananame, impl->ianacode, + ptr->interface_name, impl->actual_samples_per_second, + impl->microseconds_per_packet / 1000, impl->bits_per_second); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, + "Adding Codec %s %d %s %dhz %dms (VBR)\n", + impl->iananame, impl->ianacode, + ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_packet / 1000); + } if (!switch_core_hash_find(loadable_modules.codec_hash, impl->iananame)) { switch_core_hash_insert(loadable_modules.codec_hash, impl->iananame, (const void *) ptr); } @@ -2302,13 +2310,14 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_ uint32_t default_rate = switch_default_rate(imp->iananame, imp->ianacode); if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) { - + uint32_t crate = !strcasecmp(imp->iananame, "g722") ? imp->samples_per_second : imp->actual_samples_per_second; + if ((!interval && (uint32_t) (imp->microseconds_per_packet / 1000) != default_ptime) || (interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval)) { continue; } - if (((!rate && (uint32_t) imp->samples_per_second != default_rate) || (rate && (uint32_t) imp->samples_per_second != rate))) { + if (((!rate && crate != default_rate) || (rate && (uint32_t) imp->actual_samples_per_second != rate))) { continue; } @@ -2327,12 +2336,13 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_ /* Either looking for a specific interval or there was no interval specified and there wasn't one at the default ptime available */ for (imp = codec_interface->implementations; imp; imp = imp->next) { if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) { + uint32_t crate = !strcasecmp(imp->iananame, "g722") ? imp->samples_per_second : imp->actual_samples_per_second; if (interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval) { continue; } - if (rate && (uint32_t) imp->samples_per_second != rate) { + if (rate && (uint32_t) crate != rate) { continue; }