提交 722b8306 authored 作者: Anthony Minessale's avatar Anthony Minessale

look out below....(make current)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10363 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 c6225340
......@@ -392,6 +392,11 @@ SWITCH_DECLARE(uint32_t) switch_core_codec_next_id(void);
}
#define PROTECT_INTERFACE(_it) switch_thread_rwlock_rdlock(_it->parent->rwlock); switch_thread_rwlock_rdlock(_it->rwlock)
#define UNPROTECT_INTERFACE(_it) switch_thread_rwlock_unlock(_it->rwlock); switch_thread_rwlock_unlock(_it->parent->rwlock); _it = NULL
SWITCH_END_EXTERN_C
#endif
/* For Emacs:
......
......@@ -39,12 +39,14 @@ SWITCH_MODULE_DEFINITION(mod_dialplan_asterisk, mod_dialplan_asterisk_load, NULL
static switch_status_t exec_app(switch_core_session_t *session, char *app, char *arg)
{
const switch_application_interface_t *application_interface;
switch_status_t status = SWITCH_STATUS_FALSE;
if ((application_interface = switch_loadable_module_get_application_interface(app))) {
return switch_core_session_exec(session, application_interface, arg);
status = switch_core_session_exec(session, application_interface, arg);
UNPROTECT_INTERFACE(application_interface);
}
return SWITCH_STATUS_FALSE;
return status;
}
SWITCH_STANDARD_APP(dial_function)
......
......@@ -1168,9 +1168,9 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
} else if (!strcasecmp(val, "contact") || switch_true(val)) {
profile->pflags |= PFLAG_MULTIREG;
profile->pflags |= PFLAG_MULTIREG_CONTACT;
} else {
} else if (switch_true(val)) {
profile->pflags &= ~PFLAG_MULTIREG;
profile->pflags &= ~PFLAG_MULTIREG_CONTACT;
//profile->pflags &= ~PFLAG_MULTIREG_CONTACT;
}
} else if (!strcasecmp(var, "supress-cng") || !strcasecmp(var, "suppress-cng")) {
if (switch_true(val)) {
......@@ -1629,9 +1629,9 @@ switch_status_t config_sofia(int reload, char *profile_name)
} else if (!strcasecmp(val, "contact") || switch_true(val)) {
profile->pflags |= PFLAG_MULTIREG;
profile->pflags |= PFLAG_MULTIREG_CONTACT;
} else {
} else if (switch_true(val)) {
profile->pflags &= ~PFLAG_MULTIREG;
profile->pflags &= ~PFLAG_MULTIREG_CONTACT;
//profile->pflags &= ~PFLAG_MULTIREG_CONTACT;
}
} else if (!strcasecmp(var, "supress-cng") || !strcasecmp(var, "suppress-cng")) {
if (switch_true(val)) {
......
......@@ -2865,10 +2865,15 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", profile->odbc_dsn);
if (switch_odbc_handle_exec(profile->master_odbc, "select hostname from sip_registrations", NULL) != SWITCH_ODBC_SUCCESS) {
test_sql = switch_mprintf("delete from sip_registrations where (contact like '%%TCP%%' "
"or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q'",
mod_sofia_globals.hostname);
if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_registrations", NULL);
switch_odbc_handle_exec(profile->master_odbc, reg_sql, NULL);
}
free(test_sql);
test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q'", mod_sofia_globals.hostname);
......@@ -2898,13 +2903,18 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
#else
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
#endif
} else {
} else {
if (!(profile->master_db = switch_core_db_open_file(profile->dbname))) {
return 0;
}
switch_core_db_test_reactive(profile->master_db, "select hostname from sip_registrations", "DROP TABLE sip_registrations", reg_sql);
test_sql = switch_mprintf("delete from sip_registrations where (contact like '%%TCP%%' "
"or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q'",
mod_sofia_globals.hostname);
switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_registrations", reg_sql);
free(test_sql);
test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q'", mod_sofia_globals.hostname);
switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_subscriptions", sub_sql);
free(test_sql);
......
......@@ -249,6 +249,11 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
}
done:
if (fh.file_interface) {
switch_core_file_close(&fh);
}
source->ready = 0;
switch_mutex_lock(globals.mutex);
switch_core_hash_delete(globals.source_hash, source->name);
......
......@@ -2222,6 +2222,7 @@ static JSBool session_execute(JSContext * cx, JSObject * obj, uintN argc, jsval
check_hangup_hook(jss, &ret);
retval = JS_TRUE;
}
UNPROTECT_INTERFACE(application_interface);
}
}
......
......@@ -64,6 +64,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah,
ah->memory_pool = pool;
} else {
if ((status = switch_core_new_memory_pool(&ah->memory_pool)) != SWITCH_STATUS_SUCCESS) {
UNPROTECT_INTERFACE(ah->asr_interface);
return status;
}
switch_set_flag(ah, SWITCH_ASR_FLAG_FREE_POOL);
......@@ -127,6 +128,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_close(switch_asr_handle_t *ah, s
switch_assert(ah != NULL);
status = ah->asr_interface->asr_close(ah, flags);
UNPROTECT_INTERFACE(ah->asr_interface);
if (switch_test_flag(ah, SWITCH_ASR_FLAG_FREE_POOL)) {
switch_core_destroy_memory_pool(&ah->memory_pool);
......
......@@ -451,12 +451,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec, co
implementation->init(codec, flags, codec_settings);
switch_mutex_init(&codec->mutex, SWITCH_MUTEX_NESTED, codec->memory_pool);
return SWITCH_STATUS_SUCCESS;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec %s Exists but not at the desired implementation. %dhz %dms\n", codec_name, rate,
ms);
}
UNPROTECT_INTERFACE(codec_interface);
return SWITCH_STATUS_NOTIMPL;
}
......@@ -541,6 +544,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_destroy(switch_codec_t *codec)
if (mutex) switch_mutex_lock(mutex);
codec->implementation->destroy(codec);
UNPROTECT_INTERFACE(codec->codec_interface);
memset(codec, 0, sizeof(*codec));
if (mutex) switch_mutex_unlock(mutex);
......
......@@ -49,6 +49,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_directory_open(switch_directory_hand
dh->memory_pool = pool;
} else {
if ((status = switch_core_new_memory_pool(&dh->memory_pool)) != SWITCH_STATUS_SUCCESS) {
UNPROTECT_INTERFACE(dh->directory_interface);
return status;
}
switch_set_flag(dh, SWITCH_DIRECTORY_FLAG_FREE_POOL);
......@@ -77,6 +78,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_directory_close(switch_directory_han
switch_status_t status;
status = dh->directory_interface->directory_close(dh);
UNPROTECT_INTERFACE(dh->directory_interface);
if (switch_test_flag(dh, SWITCH_DIRECTORY_FLAG_FREE_POOL)) {
switch_core_destroy_memory_pool(&dh->memory_pool);
......
......@@ -76,6 +76,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
fh->memory_pool = pool;
} else {
if ((status = switch_core_new_memory_pool(&fh->memory_pool)) != SWITCH_STATUS_SUCCESS) {
UNPROTECT_INTERFACE(fh->file_interface);
return status;
}
switch_set_flag(fh, SWITCH_FILE_FLAG_FREE_POOL);
......@@ -98,9 +99,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
}
if ((status = fh->file_interface->file_open(fh, file_path)) != SWITCH_STATUS_SUCCESS) {
UNPROTECT_INTERFACE(fh->file_interface);
return status;
}
if ((flags & SWITCH_FILE_FLAG_READ)) {
fh->native_rate = fh->samplerate;
} else {
......@@ -281,6 +284,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh)
switch_resample_destroy(&fh->resampler);
UNPROTECT_INTERFACE(fh->file_interface);
if (switch_test_flag(fh, SWITCH_FILE_FLAG_FREE_POOL)) {
switch_core_destroy_memory_pool(&fh->memory_pool);
}
......
......@@ -87,11 +87,13 @@ SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(const char *var_nam
if (val) {
const char *this_val;
session = (switch_core_session_t *) val;
switch_core_session_read_lock(session);
if ((this_val = switch_channel_get_variable(session->channel, var_name)) && (!strcmp(this_val, var_val))) {
switch_channel_hangup(switch_core_session_get_channel(session), cause);
if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
if (switch_channel_get_state(session->channel) < CS_HANGUP &&
(this_val = switch_channel_get_variable(session->channel, var_name)) && (!strcmp(this_val, var_val))) {
switch_channel_hangup(session->channel, cause);
}
switch_core_session_rwunlock(session);
}
switch_core_session_rwunlock(session);
}
}
switch_mutex_unlock(runtime.throttle_mutex);
......@@ -826,8 +828,7 @@ SWITCH_DECLARE(void) switch_core_session_perform_destroy(switch_core_session_t *
*session = NULL;
switch_core_destroy_memory_pool(&pool);
switch_thread_rwlock_unlock(endpoint_interface->rwlock);
switch_thread_rwlock_unlock(endpoint_interface->parent->rwlock);
UNPROTECT_INTERFACE(endpoint_interface);
}
SWITCH_STANDARD_SCHED_FUNC(sch_heartbeat_callback)
......@@ -1006,6 +1007,7 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(const s
uint32_t count = 0;
int32_t sps = 0;
if (use_uuid && switch_core_hash_find(session_manager.session_table, use_uuid)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Duplicate UUID!\n");
return NULL;
......@@ -1016,6 +1018,8 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(const s
return NULL;
}
PROTECT_INTERFACE(endpoint_interface);
switch_mutex_lock(runtime.throttle_mutex);
count = session_manager.session_count;
sps = --runtime.sps;
......@@ -1023,17 +1027,16 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(const s
if (sps <= 0) {
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Throttle Error!\n");
UNPROTECT_INTERFACE(endpoint_interface);
return NULL;
}
if ((count + 1) > session_manager.session_limit) {
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Over Session Limit!\n");
UNPROTECT_INTERFACE(endpoint_interface);
return NULL;
}
switch_thread_rwlock_rdlock(endpoint_interface->parent->rwlock);
switch_thread_rwlock_rdlock(endpoint_interface->rwlock);
if (pool && *pool) {
usepool = *pool;
*pool = NULL;
......@@ -1114,7 +1117,9 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(cons
return NULL;
}
UNPROTECT_INTERFACE(endpoint_interface);
return switch_core_session_request(endpoint_interface, pool);
}
#ifndef SWITCH_PREFIX_DIR
......@@ -1195,6 +1200,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application(switch_c
if (!application_interface->application_function) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Function for %s\n", app);
switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
UNPROTECT_INTERFACE(application_interface);
return SWITCH_STATUS_FALSE;
}
......@@ -1236,6 +1242,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application(switch_c
switch_safe_free(expanded);
}
UNPROTECT_INTERFACE(application_interface);
return SWITCH_STATUS_SUCCESS;
}
......@@ -1282,11 +1290,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
switch_channel_set_variable(session->channel, SWITCH_CURRENT_APPLICATION_VARIABLE, application_interface->interface_name);
switch_thread_rwlock_rdlock(application_interface->parent->rwlock);
switch_thread_rwlock_rdlock(application_interface->rwlock);
application_interface->application_function(session, arg);
switch_thread_rwlock_unlock(application_interface->rwlock);
switch_thread_rwlock_unlock(application_interface->parent->rwlock);
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event);
......
......@@ -66,6 +66,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *
sh->memory_pool = pool;
} else {
if ((status = switch_core_new_memory_pool(&sh->memory_pool)) != SWITCH_STATUS_SUCCESS) {
UNPROTECT_INTERFACE(sh->speech_interface);
return status;
}
switch_set_flag(sh, SWITCH_SPEECH_FLAG_FREE_POOL);
......@@ -139,6 +140,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_speech_close(switch_speech_handle_t
{
switch_status_t status = sh->speech_interface->speech_close(sh, flags);
UNPROTECT_INTERFACE(sh->speech_interface);
if (switch_test_flag(sh, SWITCH_SPEECH_FLAG_FREE_POOL)) {
switch_core_destroy_memory_pool(&sh->memory_pool);
}
......
......@@ -91,8 +91,11 @@ static void switch_core_standard_on_routing(switch_core_session_t *session)
}
count++;
if ((extension = dialplan_interface->hunt_function(session, dparg, NULL)) != 0) {
extension = dialplan_interface->hunt_function(session, dparg, NULL);
UNPROTECT_INTERFACE(dialplan_interface);
if (extension) {
switch_channel_set_caller_extension(session->channel, extension);
switch_channel_set_state(session->channel, CS_EXECUTE);
goto end;
......
......@@ -55,6 +55,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, co
timer->memory_pool = pool;
} else {
if ((status = switch_core_new_memory_pool(&timer->memory_pool)) != SWITCH_STATUS_SUCCESS) {
UNPROTECT_INTERFACE(timer->timer_interface);
return status;
}
switch_set_flag(timer, SWITCH_TIMER_FLAG_FREE_POOL);
......@@ -120,6 +121,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_timer_destroy(switch_timer_t *timer)
}
timer->timer_interface->timer_destroy(timer);
UNPROTECT_INTERFACE(timer->timer_interface);
if (switch_test_flag(timer, SWITCH_TIMER_FLAG_FREE_POOL)) {
switch_core_destroy_memory_pool(&timer->memory_pool);
......
......@@ -409,6 +409,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
switch_channel_clear_flag(channel, CF_BROADCAST);
}
UNPROTECT_INTERFACE(application_interface);
}
}
} else if (cmd_hash == CMD_UNICAST) {
......
......@@ -477,6 +477,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s
if ((application_interface = switch_loadable_module_get_application_interface(app_name))) {
switch_core_session_exec(session, application_interface, app_arg);
UNPROTECT_INTERFACE(application_interface);
status = SWITCH_STATUS_SUCCESS;
}
}
......
......@@ -115,6 +115,7 @@ static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t *thread, void
if ((application_interface = switch_loadable_module_get_application_interface(app_name)) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n", app_name);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
UNPROTECT_INTERFACE(application_interface);
goto wbreak;
}
......
......@@ -293,6 +293,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
if ((app = switch_loadable_module_get_application_interface(cmd)) != NULL) {
status = switch_core_session_exec(session, app, cmd_args);
UNPROTECT_INTERFACE(app);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n", cmd);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论