diff --git a/configure.in b/configure.in index 465edafc39..c0eb5a545d 100644 --- a/configure.in +++ b/configure.in @@ -3,10 +3,10 @@ # Must change all of the below together # For a release, set revision for that tagged release as well and uncomment -AC_INIT([freeswitch], [1.2.5], BUG-REPORT-ADDRESS) +AC_INIT([freeswitch], [1.2.5.1], BUG-REPORT-ADDRESS) AC_SUBST(SWITCH_VERSION_MAJOR, [1]) AC_SUBST(SWITCH_VERSION_MINOR, [2]) -AC_SUBST(SWITCH_VERSION_MICRO, [5]) +AC_SUBST(SWITCH_VERSION_MICRO, [5.1]) AC_SUBST(SWITCH_VERSION_REVISION, []) AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, []) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 15993c7993..20c83cd898 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -466,7 +466,6 @@ typedef struct { struct switch_directories { char *base_dir; char *mod_dir; - char *lib_dir; char *conf_dir; char *log_dir; char *run_dir; @@ -478,6 +477,7 @@ struct switch_directories { char *storage_dir; char *recordings_dir; char *sounds_dir; + char *lib_dir; }; typedef struct switch_directories switch_directories; diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index eefd4aad4b..d672e2a3db 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -4476,8 +4476,13 @@ static switch_status_t next_file(switch_file_handle_t *handle) } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error finding the folder path section in '%s'\n", path); } - } + + if (switch_file_exists(file, handle->memory_pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "File [%s] does not exist.\n", file); + goto top; + } + if (switch_core_file_open(&context->fh, file, handle->channels, handle->samplerate, handle->flags, NULL) != SWITCH_STATUS_SUCCESS) { goto top; } diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 24a0e497a9..2878968ddf 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -1264,6 +1264,9 @@ static int activate_audio_rtp(struct private_object *tech_pvt) switch_rtp_set_ssrc(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, tech_pvt->transports[LDL_TPORT_RTP].ssrc); + switch_rtp_intentional_bugs(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, RTP_BUG_GEN_ONE_GEN_ALL); + + if (tech_pvt->transports[LDL_TPORT_RTCP].remote_port) { switch_rtp_activate_rtcp(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, MDL_RTCP_DUR, tech_pvt->transports[LDL_TPORT_RTCP].remote_port); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 5240553caa..45f73c5866 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -600,6 +600,7 @@ struct sofia_profile { sofia_dtmf_t dtmf_type; int auto_restart; switch_port_t sip_port; + switch_port_t extsipport; switch_port_t tls_sip_port; int tls_version; unsigned int tls_timeout; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index b4d3e894a3..092b1dca27 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -2212,7 +2212,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread if (!sofia_test_pflag(profile, PFLAG_STANDBY)) { - if (++ireg_loops >= IREG_SECONDS) { + if (++ireg_loops >= profile->ireg_seconds) { time_t now = switch_epoch_time_now(NULL); sofia_reg_check_expire(profile, now, 0); ireg_loops = 0; @@ -3988,6 +3988,9 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) ip = strcasecmp(val, "auto") ? val : mod_sofia_globals.guess_ip; } profile->sipip = switch_core_strdup(profile->pool, ip); + } else if (!strcasecmp(var, "ext-sip-port") && val) { + int tmp = atoi(val); + if (tmp > 0) profile->extsipport = tmp; } else if (!strcasecmp(var, "ext-sip-ip")) { if (!zstr(val)) { char *ip = mod_sofia_globals.guess_ip; @@ -4002,8 +4005,11 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } else if (!strcasecmp(val, "auto-nat")) { ip = NULL; } else if (strcasecmp(val, "auto")) { - switch_port_t port = 0; - if (sofia_glue_ext_address_lookup(profile, NULL, &myip, &port, val, profile->pool) == SWITCH_STATUS_SUCCESS) { + if (!profile->extsipport) { + profile->extsipport = profile->sip_port; + } + + if (sofia_glue_ext_address_lookup(profile, NULL, &myip, &profile->extsipport, val, profile->pool) == SWITCH_STATUS_SUCCESS) { ip = myip; sofia_clear_pflag(profile, PFLAG_AUTO_NAT); } else { @@ -4666,6 +4672,11 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } if (profile->sipip) { + + if (!profile->extsipport) { + profile->extsipport = profile->sip_port; + } + launch_sofia_profile_thread(profile); if (profile->odbc_dsn) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Connecting ODBC Profile %s [%s]\n", profile->name, url); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 37caeba651..31ea2bb66b 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1373,7 +1373,7 @@ const char *sofia_glue_transport2str(const sofia_transport_t tp) char *sofia_glue_create_external_via(switch_core_session_t *session, sofia_profile_t *profile, sofia_transport_t transport) { return sofia_glue_create_via(session, profile->extsipip, (sofia_glue_transport_has_tls(transport)) - ? profile->tls_sip_port : profile->sip_port, transport); + ? profile->tls_sip_port : profile->extsipport, transport); } char *sofia_glue_create_via(switch_core_session_t *session, const char *ip, switch_port_t port, sofia_transport_t transport) diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index e11d96ff76..53b524a236 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -873,13 +873,13 @@ static void do_dialog_probe(switch_event_t *event) if (mod_sofia_globals.debug_presence > 1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s DUMP DIALOG_PROBE set version sql:\n%s\n", profile->name, sql); } - sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); + sofia_glue_execute_sql_soon(profile, &sql, SWITCH_TRUE); switch_safe_free(sql); // The dialog_probe_callback has built up the dialogs to be included in the NOTIFY. // Now send the "full" dialog event to the triggering subscription. - sql = switch_mprintf("select call_id,expires,sub_to_user,sub_to_host,event,version, " + sql = switch_mprintf("select call_id,expires,sub_to_user,sub_to_host,event,version+1, " "'full',full_to,full_from,contact,network_ip,network_port " "from sip_subscriptions " "where hostname='%q' and profile_name='%q' and sub_to_user='%q' and sub_to_host='%q' and call_id='%q'", @@ -4543,7 +4543,7 @@ void sofia_presence_check_subscriptions(sofia_profile_t *profile, time_t now) "((expires > 0 and expires <= %ld)) and profile_name='%q' and hostname='%q'", (long) now, profile->name, mod_sofia_globals.hostname); - sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); + sofia_glue_execute_sql_soon(profile, &sql, SWITCH_TRUE); switch_safe_free(sql); sql = switch_mprintf("select full_to, full_from, contact, -1, call_id, event, network_ip, network_port, " diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 79b49c1b6b..2dbdeaf5a8 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -1595,8 +1595,12 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand } else { sql = switch_mprintf("update sip_registrations set " "sub_host='%q', network_ip='%q',network_port='%q'," + "presence_hosts='%q', server_host='%q', orig_server_host='%q'," + "hostname='%q', orig_hostname='%q'," "expires = %ld where sip_user='%q' and sip_username='%q' and sip_host='%q' and contact='%q'", sub_host, network_ip, network_port_c, + profile->presence_hosts ? profile->presence_hosts : "", guess_ip4, guess_ip4, + mod_sofia_globals.hostname, mod_sofia_globals.hostname, (long) switch_epoch_time_now(NULL) + (long) exptime + 60, to_user, username, reg_host, contact_str); } @@ -2014,9 +2018,9 @@ void sofia_reg_handle_sip_r_register(int status, expi = (uint32_t) atoi(new_expires); if (expi > 0 && expi != sofia_private->gateway->freq) { - sofia_private->gateway->freq = expi; - sofia_private->gateway->expires_str = switch_core_sprintf(sofia_private->gateway->pool, "%d", expi); - + //sofia_private->gateway->freq = expi; + //sofia_private->gateway->expires_str = switch_core_sprintf(sofia_private->gateway->pool, "%d", expi); + if (expi > 60) { sofia_private->gateway->expires = switch_epoch_time_now(NULL) + (expi - 15); } else { diff --git a/src/mod/loggers/mod_logfile/mod_logfile.c b/src/mod/loggers/mod_logfile/mod_logfile.c index db78909134..ee41c021a8 100644 --- a/src/mod/loggers/mod_logfile/mod_logfile.c +++ b/src/mod/loggers/mod_logfile/mod_logfile.c @@ -161,7 +161,8 @@ static switch_status_t mod_logfile_rotate(logfile_profile_t *profile) } if ((status = switch_file_rename(from_filename, to_filename, pool)) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error renaming log from %s to %s\n",from_filename, to_filename); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error renaming log from %s to %s [%s]\n", + from_filename, to_filename, strerror(errno)); goto end; } } @@ -170,19 +171,19 @@ static switch_status_t mod_logfile_rotate(logfile_profile_t *profile) if (switch_file_exists(to_filename, pool) == SWITCH_STATUS_SUCCESS) { if ((status = switch_file_remove(to_filename, pool)) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error removing log %s\n",to_filename); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error removing log %s [%s]\n", to_filename, strerror(errno)); goto end; } } switch_file_close(profile->log_afd); if ((status = switch_file_rename(profile->logfile, to_filename, pool)) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error renaming log from %s to %s\n", profile->logfile, to_filename); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error renaming log from %s to %s [%s]\n", profile->logfile, to_filename, strerror(errno)); goto end; } if ((status = mod_logfile_openlogfile(profile, SWITCH_FALSE)) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error reopening log %s\n",profile->logfile); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error reopening log %s\n", profile->logfile); } if (profile->suffix < profile->max_rot) { profile->suffix++; diff --git a/src/switch_core.c b/src/switch_core.c index 4682d3c002..1cc0dd0569 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -670,6 +670,9 @@ SWITCH_DECLARE(void) switch_core_set_globals(void) #ifdef WIN32 GetTempPath(dwBufSize, lpPathBuffer); lpPathBuffer[strlen(lpPathBuffer)-1] = 0; + tmp = switch_string_replace(lpPathBuffer, "\\", "/"); + strcpy(lpPathBuffer, tmp); + free(tmp); switch_snprintf(SWITCH_GLOBAL_dirs.temp_dir, BUFSIZE, "%s", lpPathBuffer); #else switch_snprintf(SWITCH_GLOBAL_dirs.temp_dir, BUFSIZE, "%s", "/tmp"); diff --git a/src/switch_core_file.c b/src/switch_core_file.c index b1a1effc85..ae040b31be 100644 --- a/src/switch_core_file.c +++ b/src/switch_core_file.c @@ -42,7 +42,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, uint8_t channels, uint32_t rate, unsigned int flags, switch_memory_pool_t *pool) { char *ext; - switch_status_t status; + switch_status_t status = SWITCH_STATUS_FALSE; char stream_name[128] = ""; char *rhs = NULL; const char *spool_path = NULL; @@ -76,6 +76,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, switch_set_flag(fh, SWITCH_FILE_FLAG_FREE_POOL); } + if (switch_directory_exists(file_path, fh->memory_pool) == SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "File [%s] is a directory not a file.\n", file_path); + goto fail; + } if ((rhs = strstr(file_path, SWITCH_URL_SEPARATOR))) { switch_copy_string(stream_name, file_path, (rhs + 1) - file_path); @@ -198,6 +202,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, fail: + switch_clear_flag(fh, SWITCH_FILE_OPEN); + if (switch_test_flag(fh, SWITCH_FILE_FLAG_FREE_POOL)) { switch_core_destroy_memory_pool(&fh->memory_pool); } diff --git a/src/switch_core_media_bug.c b/src/switch_core_media_bug.c index b8b83da6bd..b0d9e8d4f9 100644 --- a/src/switch_core_media_bug.c +++ b/src/switch_core_media_bug.c @@ -247,7 +247,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b if (read_impl.actual_samples_per_second == other_read_impl.actual_samples_per_second) { if (read_impl.decoded_bytes_per_packet < other_read_impl.decoded_bytes_per_packet) { - frame_size = other_read_impl.decoded_bytes_per_packet; + frame_size = read_impl.decoded_bytes_per_packet; } } else { if (read_impl.decoded_bytes_per_packet > other_read_impl.decoded_bytes_per_packet) { diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index b776a14a87..c8cdfe049e 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -144,7 +144,7 @@ static switch_cache_db_handle_t *get_handle(const char *db_str, const char *user switch_mutex_lock(sql_manager.dbh_mutex); for (dbh_ptr = sql_manager.handle_pool; dbh_ptr; dbh_ptr = dbh_ptr->next) { - if (dbh_ptr->thread_hash == thread_hash && dbh_ptr->hash == hash && + if (dbh_ptr->thread_hash == thread_hash && dbh_ptr->hash == hash && !dbh_ptr->use_count && !switch_test_flag(dbh_ptr, CDF_PRUNE) && switch_mutex_trylock(dbh_ptr->mutex) == SWITCH_STATUS_SUCCESS) { r = dbh_ptr; } @@ -1314,10 +1314,12 @@ SWITCH_DECLARE(switch_status_t) switch_sql_queue_manager_start(switch_sql_queue_ } -static void do_flush(switch_queue_t *q, switch_cache_db_handle_t *dbh) +static void do_flush(switch_sql_queue_manager_t *qm, int i, switch_cache_db_handle_t *dbh) { void *pop = NULL; - + switch_queue_t *q = qm->sql_queue[i]; + + switch_mutex_lock(qm->mutex); while (switch_queue_trypop(q, &pop) == SWITCH_STATUS_SUCCESS) { if (pop) { if (dbh) { @@ -1326,6 +1328,7 @@ static void do_flush(switch_queue_t *q, switch_cache_db_handle_t *dbh) free(pop); } } + switch_mutex_unlock(qm->mutex); } @@ -1347,7 +1350,7 @@ SWITCH_DECLARE(switch_status_t) switch_sql_queue_manager_destroy(switch_sql_queu for(i = 0; i < qm->numq; i++) { - do_flush(qm->sql_queue[i], NULL); + do_flush(qm, i, NULL); } pool = qm->pool; @@ -1406,7 +1409,7 @@ SWITCH_DECLARE(switch_status_t) switch_sql_queue_manager_push_confirm(switch_sql switch_mutex_lock(qm->mutex); switch_queue_push(qm->sql_queue[pos], dup ? strdup(sql) : (char *)sql); - written = qm->written[pos]; + written = qm->pre_written[pos]; size = switch_sql_queue_manager_size(qm, pos); want = written + size; switch_mutex_unlock(qm->mutex); @@ -1491,12 +1494,6 @@ static uint32_t do_trans(switch_sql_queue_manager_t *qm) if (io_mutex) switch_mutex_lock(io_mutex); - switch_mutex_lock(qm->mutex); - for (i = 0; i < qm->numq; i++) { - qm->pre_written[i] = 0; - } - switch_mutex_unlock(qm->mutex); - if (!zstr(qm->pre_trans_execute)) { switch_cache_db_execute_sql_real(qm->event_db, qm->pre_trans_execute, &errmsg); if (errmsg) { @@ -1563,7 +1560,9 @@ static uint32_t do_trans(switch_sql_queue_manager_t *qm) if (pop) { if ((status = switch_cache_db_execute_sql(qm->event_db, (char *) pop, NULL)) == SWITCH_STATUS_SUCCESS) { + switch_mutex_lock(qm->mutex); qm->pre_written[i]++; + switch_mutex_unlock(qm->mutex); ttl++; } free(pop); @@ -1618,7 +1617,7 @@ static uint32_t do_trans(switch_sql_queue_manager_t *qm) switch_mutex_lock(qm->mutex); for (i = 0; i < qm->numq; i++) { - qm->written[i] += qm->pre_written[i]; + qm->written[i] = qm->pre_written[i]; } switch_mutex_unlock(qm->mutex); @@ -1633,7 +1632,7 @@ static void *SWITCH_THREAD_FUNC switch_user_sql_thread(switch_thread_t *thread, uint32_t sanity = 120; switch_sql_queue_manager_t *qm = (switch_sql_queue_manager_t *) obj; - uint32_t i, countdown = 0; + uint32_t i; while (!qm->event_db) { if (switch_cache_db_get_db_handle_dsn(&qm->event_db, qm->dsn) == SWITCH_STATUS_SUCCESS && qm->event_db) @@ -1670,17 +1669,20 @@ static void *SWITCH_THREAD_FUNC switch_user_sql_thread(switch_thread_t *thread, while (qm->thread_running == 1) { uint32_t i, lc; - uint32_t written, iterations = 0; + uint32_t written = 0, iterations = 0; if (sql_manager.paused) { for (i = 0; i < qm->numq; i++) { - do_flush(qm->sql_queue[i], NULL); + do_flush(qm, i, NULL); } goto check; } do { - written = do_trans(qm); + if (!qm_ttl(qm)) { + goto check; + } + written = do_trans(qm); iterations += written; } while(written == qm->max_trans); @@ -1704,21 +1706,18 @@ static void *SWITCH_THREAD_FUNC switch_user_sql_thread(switch_thread_t *thread, check: - countdown = 40; - - while (--countdown && (lc = qm_ttl(qm)) < qm->max_trans / 4) { - if (lc == 0) { - switch_thread_cond_wait(qm->cond, qm->cond_mutex); - break; + if ((lc = qm_ttl(qm)) < qm->max_trans / 4) { + switch_yield(500000); + if ((lc = qm_ttl(qm)) == 0) { + switch_thread_cond_wait(qm->cond, qm->cond_mutex); } - switch_yield(5000); } } switch_mutex_unlock(qm->cond_mutex); for(i = 0; i < qm->numq; i++) { - do_flush(qm->sql_queue[i], qm->event_db); + do_flush(qm, i, qm->event_db); } qm->thread_running = 0; diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 18329714aa..dd5055351c 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -1390,6 +1390,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, switch_channel_t *channel = switch_core_session_get_channel(session); const char *stream; const char *other_uuid; + switch_event_t *event; msg.message_id = SWITCH_MESSAGE_INDICATE_HOLD; msg.string_arg = message; @@ -1406,6 +1407,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, } } + if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_HOLD) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_fire(&event); + } + return SWITCH_STATUS_SUCCESS; } @@ -1428,6 +1434,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_unhold(switch_core_session_t *session switch_channel_t *channel = switch_core_session_get_channel(session); const char *other_uuid; switch_core_session_t *b_session; + switch_event_t *event; msg.message_id = SWITCH_MESSAGE_INDICATE_UNHOLD; msg.from = __FILE__; @@ -1446,6 +1453,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_unhold(switch_core_session_t *session } + if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNHOLD) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_fire(&event); + } + return SWITCH_STATUS_SUCCESS; } diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 73c1db88b0..e469066fce 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -341,9 +341,10 @@ static void do_2833(switch_rtp_t *rtp_session, switch_core_session_t *session); static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_size_t bytes, int *do_cng) { + #ifdef DEBUG_2833 if (rtp_session->dtmf_data.in_digit_sanity && !(rtp_session->dtmf_data.in_digit_sanity % 100)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "sanity %d\n", rtp_session->dtmf_data.in_digit_sanity); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "sanity %d\n", rtp_session->dtmf_data.in_digit_sanity); } #endif @@ -396,8 +397,7 @@ static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_ } } #ifdef DEBUG_2833 - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "packet[%d]: %02x %02x %02x %02x\n", (int) len, (unsigned) packet[0], (unsigned) - packet[1], (unsigned) packet[2], (unsigned) packet[3]); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "packet[%d]: %02x %02x %02x %02x\n", (int) len, (unsigned) packet[0], (unsigned) packet[1], (unsigned) packet[2], (unsigned) packet[3]); #endif if (in_digit_seq > rtp_session->dtmf_data.in_digit_seq) { @@ -405,7 +405,7 @@ static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_ rtp_session->dtmf_data.in_digit_seq = in_digit_seq; #ifdef DEBUG_2833 - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "read: %c %u %u %u %u %d %d %s\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "read: %c %u %u %u %u %d %d %s\n", key, in_digit_seq, rtp_session->dtmf_data.in_digit_seq, ts, duration, rtp_session->recv_msg.header.m, end, end && !rtp_session->dtmf_data.in_digit_ts ? "ignored" : ""); #endif @@ -414,7 +414,7 @@ static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_ rtp_session->dtmf_data.in_digit_ts) { switch_dtmf_t dtmf = { key, switch_core_min_dtmf_duration(0), 0, SWITCH_DTMF_RTP }; #ifdef DEBUG_2833 - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Early Queuing digit %c:%d\n", dtmf.digit, dtmf.duration / 8); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Early Queuing digit %c:%d\n", dtmf.digit, dtmf.duration / 8); #endif switch_rtp_queue_rfc2833_in(rtp_session, &dtmf); rtp_session->dtmf_data.in_digit_queued = 1; @@ -433,7 +433,7 @@ static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_ if (end) { if (!rtp_session->dtmf_data.in_digit_ts && rtp_session->dtmf_data.last_in_digit_ts != ts) { #ifdef DEBUG_2833 - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "start with end packet %d\n", ts); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "start with end packet %d\n", ts); #endif rtp_session->dtmf_data.last_in_digit_ts = ts; rtp_session->dtmf_data.in_digit_ts = ts; @@ -450,17 +450,17 @@ static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_ dtmf.duration += rtp_session->dtmf_data.flip * 0xFFFF; rtp_session->dtmf_data.flip = 0; #ifdef DEBUG_2833 - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "you're welcome!\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "you're welcome!\n"); #endif } #ifdef DEBUG_2833 - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "done digit=%c ts=%u start_ts=%u dur=%u ddur=%u\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "done digit=%c ts=%u start_ts=%u dur=%u ddur=%u\n", dtmf.digit, ts, rtp_session->dtmf_data.in_digit_ts, duration, dtmf.duration); #endif if (!(rtp_session->rtp_bugs & RTP_BUG_IGNORE_DTMF_DURATION) && !rtp_session->dtmf_data.in_digit_queued) { #ifdef DEBUG_2833 - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Queuing digit %c:%d\n", dtmf.digit, dtmf.duration / 8); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Queuing digit %c:%d\n", dtmf.digit, dtmf.duration / 8); #endif switch_rtp_queue_rfc2833_in(rtp_session, &dtmf); } @@ -481,7 +481,7 @@ static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_ } else if (!rtp_session->dtmf_data.in_digit_ts) { #ifdef DEBUG_2833 - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "start %d\n", ts); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "start %d\n", ts); #endif rtp_session->dtmf_data.in_digit_ts = ts; rtp_session->dtmf_data.last_in_digit_ts = ts; @@ -492,7 +492,7 @@ static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_ rtp_session->dtmf_data.last_duration = duration; } else { #ifdef DEBUG_2833 - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "drop: %c %u %u %u %u %d %d\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "drop: %c %u %u %u %u %d %d\n", key, in_digit_seq, rtp_session->dtmf_data.in_digit_seq, ts, duration, rtp_session->recv_msg.header.m, end); #endif switch_cond_next(); @@ -2822,7 +2822,7 @@ static void do_flush(switch_rtp_t *rtp_session) if (bytes > rtp_header_len && rtp_session->recv_te && rtp_session->recv_msg.header.pt == rtp_session->recv_te) { handle_rfc2833(rtp_session, bytes, &do_cng); #ifdef DEBUG_2833 - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "*** RTP packet handled in flush loop %d ***\n", do_cng); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "*** RTP packet handled in flush loop %d ***\n", do_cng); #endif } diff --git a/src/switch_utils.c b/src/switch_utils.c index fad8530245..4335b4dcd3 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -876,12 +876,16 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, } } + if (fd > -1) { + close(fd); + fd = -1; + } if (zstr(from)) { from = "freeswitch"; } #ifdef WIN32 - switch_snprintf(buf, B64BUFFLEN, "type \"%s\" | \"%s\" -f %s %s %s", filename, runtime.mailer_app, from, runtime.mailer_app_args, to); + switch_snprintf(buf, B64BUFFLEN, "\"\"%s\" -f %s %s %s < \"%s\"\"", runtime.mailer_app, from, runtime.mailer_app_args, to, filename); #else switch_snprintf(buf, B64BUFFLEN, "/bin/cat %s | %s -f %s %s %s", filename, runtime.mailer_app, from, runtime.mailer_app_args, to); #endif