]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
switch_core: Add capability to specify core-db-name in switch.conf.xml to have sqlite...
authorMarc Olivier Chouinard <mochouinard@moctel.com>
Tue, 15 Feb 2011 06:49:41 +0000 (01:49 -0500)
committerMarc Olivier Chouinard <mochouinard@moctel.com>
Tue, 15 Feb 2011 06:49:41 +0000 (01:49 -0500)
conf/autoload_configs/switch.conf.xml
src/include/private/switch_core_pvt.h
src/switch_core.c
src/switch_core_sqldb.c

index 44893b931a1184218acd19915a5af28510eef3f9..95c43331e413471916b6c8f8b792f5809d0a377a 100644 (file)
@@ -94,6 +94,8 @@
     <!--<param name="rtp-end-port" value="32768"/>-->
     <param name="rtp-enable-zrtp" value="true"/>
     <!-- <param name="core-db-dsn" value="dsn:username:password" /> -->
+    <!-- Allow to specify the sqlite db at a different location (In this example, move it to ramdrive for better performance on most linux distro (note, you loose the data if you reboot)) -->
+    <!-- <param name="core-db-name" value="/dev/shm/core.db" /> -->
     <!-- The system will create all the db schemas automatically, set this to false to avoid this behaviour-->
     <!--<param name="auto-create-schemas" value="true"/>-->
         <!-- <param name="core-dbtype" value="MSSQL"/> -->
index 05cd24d230eadb8a08de60a9566ca96961d7b3e3..f8c6a794b965a5313f7a48953203eea88cab31e3 100644 (file)
@@ -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;
index 0eb51ccab337faf94b28d9800347e70dc10a8ff3..66731b61c85c762916586aa5370557373fff3945 100644 (file)
@@ -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);
index f54bd650fead700dc78b60d06bbc3f7169dd36fe..120b2565cfcb80d73b051224a287579873d7ce41 100644 (file)
@@ -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);
        }