]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add core-db-pre-trans-execute and core-db-post-trans-execute to switch.conf.xml to...
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 26 Apr 2012 16:12:11 +0000 (11:12 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 26 Apr 2012 16:12:16 +0000 (11:12 -0500)
src/include/private/switch_core_pvt.h
src/switch_core.c
src/switch_core_sqldb.c

index 196f10e4f25b173afd461727daa0576d579d5143..f1d58688e46ae58fee4c0bd162d340882bf0c80f 100644 (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;
index a7259ce18ddb6bab0db0d8961c3fd363d5a84745..5f47c68f0e0c7c2ae1fc94ea8cfb1ae728b3c243 100644 (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) {
index d436c60596b8e18a942ca4631a70374c84d7c7b3..eed753b840fe792107f6e42746d37d75c0ee6e2f 100644 (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;