add core-db-pre-trans-execute and core-db-post-trans-execute to switch.conf.xml to wrap sql stmts around the core transactions

This commit is contained in:
Anthony Minessale 2012-04-26 11:12:11 -05:00
parent 8a4f273fd8
commit 21b1ffbf25
3 changed files with 22 additions and 0 deletions

View File

@ -261,6 +261,8 @@ struct switch_runtime {
uint32_t db_handle_timeout;
int cpu_count;
uint32_t time_sync;
char *core_db_pre_trans_execute;
char *core_db_post_trans_execute;
};
extern struct switch_runtime runtime;

View File

@ -1723,6 +1723,10 @@ static void switch_load_core_config(const char *file)
switch_set_flag((&runtime), SCF_EARLY_HANGUP);
} else if (!strcasecmp(var, "colorize-console") && switch_true(val)) {
runtime.colorize_console = SWITCH_TRUE;
} else if (!strcasecmp(var, "core-db-pre-trans-execute") && !zstr(val)) {
runtime.core_db_pre_trans_execute = switch_core_strdup(runtime.memory_pool, val);
} else if (!strcasecmp(var, "core-db-post-trans-execute") && !zstr(val)) {
runtime.core_db_post_trans_execute = switch_core_strdup(runtime.memory_pool, val);
} else if (!strcasecmp(var, "mailer-app") && !zstr(val)) {
runtime.mailer_app = switch_core_strdup(runtime.memory_pool, val);
} else if (!strcasecmp(var, "mailer-app-args") && val) {

View File

@ -731,6 +731,14 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_
if (io_mutex) switch_mutex_lock(io_mutex);
if (!zstr(runtime.core_db_pre_trans_execute)) {
switch_cache_db_execute_sql_real(dbh, runtime.core_db_pre_trans_execute, &errmsg);
if (errmsg) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL PRE TRANS EXEC [%s]\n", errmsg);
free(errmsg);
}
}
again:
while (begin_retries > 0) {
@ -810,6 +818,14 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_
switch_odbc_SQLSetAutoCommitAttr(dbh->native_handle.odbc_dbh, 1);
}
if (!zstr(runtime.core_db_post_trans_execute)) {
switch_cache_db_execute_sql_real(dbh, runtime.core_db_post_trans_execute, &errmsg);
if (errmsg) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL POST TRANS EXEC [%s]\n", errmsg);
free(errmsg);
}
}
if (io_mutex) switch_mutex_unlock(io_mutex);
return status;