From 500e9acd254e1e2b50d07aec2fe1241fe3e18aba Mon Sep 17 00:00:00 2001 From: Marc Olivier Chouinard Date: Tue, 15 Feb 2011 01:49:41 -0500 Subject: [PATCH] switch_core: Add capability to specify core-db-name in switch.conf.xml to have sqlite in a different location. This is important for everyone with relatively 'high' sip registration since the addition of sip registration to the core require sqlite db to be moved to a faster location (Ramdisk for example). Useful for everyone who moved their sqlite db for sofia to ramdisk because of performance issue. --- conf/autoload_configs/switch.conf.xml | 2 ++ src/include/private/switch_core_pvt.h | 1 + src/switch_core.c | 3 +++ src/switch_core_sqldb.c | 6 +++++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/conf/autoload_configs/switch.conf.xml b/conf/autoload_configs/switch.conf.xml index 44893b931a..95c43331e4 100644 --- a/conf/autoload_configs/switch.conf.xml +++ b/conf/autoload_configs/switch.conf.xml @@ -94,6 +94,8 @@ + + diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index 05cd24d230..f8c6a794b9 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -236,6 +236,7 @@ struct switch_runtime { char *odbc_dsn; char *odbc_user; char *odbc_pass; + char *dbname; uint32_t debug_level; uint32_t runlevel; uint32_t tipping_point; diff --git a/src/switch_core.c b/src/switch_core.c index 0eb51ccab3..66731b61c8 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1298,6 +1298,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc runtime.default_dtmf_duration = SWITCH_DEFAULT_DTMF_DURATION; runtime.min_dtmf_duration = SWITCH_MIN_DTMF_DURATION; runtime.odbc_dbtype = DBTYPE_DEFAULT; + runtime.dbname = NULL; /* INIT APR and Create the pool context */ if (apr_initialize() != SWITCH_STATUS_SUCCESS) { @@ -1641,6 +1642,8 @@ static void switch_load_core_config(const char *file) switch_rtp_set_start_port((switch_port_t) atoi(val)); } else if (!strcasecmp(var, "rtp-end-port") && !zstr(val)) { switch_rtp_set_end_port((switch_port_t) atoi(val)); + } else if (!strcasecmp(var, "core-db-name") && !zstr(val)) { + runtime.dbname = switch_core_strdup(runtime.memory_pool, val); } else if (!strcasecmp(var, "core-db-dsn") && !zstr(val)) { if (switch_odbc_available()) { runtime.odbc_dsn = switch_core_strdup(runtime.memory_pool, val); diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index f54bd650fe..120b2565cf 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -74,7 +74,11 @@ SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t r = _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_ODBC, &options, file, func, line); } else { - options.core_db_options.db_path = SWITCH_CORE_DB; + if (runtime.dbname) { + options.core_db_options.db_path = runtime.dbname; + } else { + options.core_db_options.db_path = SWITCH_CORE_DB; + } r = _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_CORE_DB, &options, file, func, line); }