From f1b504402b419fc54d7310c672cbe4ecb26f8ac7 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 26 Apr 2012 11:28:47 -0500 Subject: [PATCH] add core-db-inner-pre-trans-execute and core-db-inner-post-trans-execute to switch.conf.xml to wrap sql stmts inside the meat of the core transactions --- src/include/private/switch_core_pvt.h | 2 ++ src/switch_core.c | 4 ++++ src/switch_core_sqldb.c | 21 +++++++++++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index f1d58688e4..781f0e4d06 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -263,6 +263,8 @@ struct switch_runtime { uint32_t time_sync; char *core_db_pre_trans_execute; char *core_db_post_trans_execute; + char *core_db_inner_pre_trans_execute; + char *core_db_inner_post_trans_execute; }; extern struct switch_runtime runtime; diff --git a/src/switch_core.c b/src/switch_core.c index 5f47c68f0e..adb9338f68 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1727,6 +1727,10 @@ static void switch_load_core_config(const char *file) 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, "core-db-inner-pre-trans-execute") && !zstr(val)) { + runtime.core_db_inner_pre_trans_execute = switch_core_strdup(runtime.memory_pool, val); + } else if (!strcasecmp(var, "core-db-inner-post-trans-execute") && !zstr(val)) { + runtime.core_db_inner_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) { diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index eed753b840..d6c64758aa 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -734,7 +734,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_ 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); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL PRE TRANS EXEC %s [%s]\n", runtime.core_db_pre_trans_execute, errmsg); free(errmsg); } } @@ -789,6 +789,15 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_ break; } + + if (!zstr(runtime.core_db_inner_pre_trans_execute)) { + switch_cache_db_execute_sql_real(dbh, runtime.core_db_inner_pre_trans_execute, &errmsg); + if (errmsg) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL PRE TRANS EXEC %s [%s]\n", runtime.core_db_inner_pre_trans_execute, errmsg); + free(errmsg); + } + } + while (retries > 0) { switch_cache_db_execute_sql(dbh, sql, &errmsg); @@ -809,6 +818,14 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_ } } + if (!zstr(runtime.core_db_inner_post_trans_execute)) { + switch_cache_db_execute_sql_real(dbh, runtime.core_db_inner_post_trans_execute, &errmsg); + if (errmsg) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL POST TRANS EXEC %s [%s]\n", runtime.core_db_inner_post_trans_execute, errmsg); + free(errmsg); + } + } + done: if (runtime.odbc_dbtype == DBTYPE_DEFAULT) { @@ -821,7 +838,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_ 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); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL POST TRANS EXEC %s [%s]\n", runtime.core_db_post_trans_execute, errmsg); free(errmsg); } }