提交 8bd35134 authored 作者: Marc Olivier Chouinard's avatar Marc Olivier Chouinard

mod_callcenter: Add param to change the location or name of the sqlite database…

mod_callcenter: Add param to change the location or name of the sqlite database like to put it into a ramdisk
上级 4aa9a838
<configuration name="callcenter.conf" description="CallCenter"> <configuration name="callcenter.conf" description="CallCenter">
<settings> <settings>
<!--<param name="odbc-dsn" value="dsn:user:pass"/>--> <!--<param name="odbc-dsn" value="dsn:user:pass"/>-->
<!--<param name="dbname" value="/dev/shm/callcenter.db"/>-->
</settings> </settings>
<queues> <queues>
......
...@@ -402,6 +402,7 @@ static struct { ...@@ -402,6 +402,7 @@ static struct {
char *odbc_dsn; char *odbc_dsn;
char *odbc_user; char *odbc_user;
char *odbc_pass; char *odbc_pass;
char *dbname;
int32_t threads; int32_t threads;
int32_t running; int32_t running;
switch_mutex_t *mutex; switch_mutex_t *mutex;
...@@ -506,7 +507,7 @@ switch_cache_db_handle_t *cc_get_db_handle(void) ...@@ -506,7 +507,7 @@ switch_cache_db_handle_t *cc_get_db_handle(void)
dbh = NULL; dbh = NULL;
return dbh; return dbh;
} else { } else {
options.core_db_options.db_path = CC_SQLITE_DB_NAME; options.core_db_options.db_path = globals.dbname;
if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_CORE_DB, &options) != SWITCH_STATUS_SUCCESS) if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_CORE_DB, &options) != SWITCH_STATUS_SUCCESS)
dbh = NULL; dbh = NULL;
return dbh; return dbh;
...@@ -1258,6 +1259,8 @@ static switch_status_t load_config(void) ...@@ -1258,6 +1259,8 @@ static switch_status_t load_config(void)
if (!strcasecmp(var, "debug")) { if (!strcasecmp(var, "debug")) {
globals.debug = atoi(val); globals.debug = atoi(val);
} else if (!strcasecmp(var, "dbname")) {
globals.dbname = strdup(val);
} else if (!strcasecmp(var, "odbc-dsn")) { } else if (!strcasecmp(var, "odbc-dsn")) {
globals.odbc_dsn = strdup(val); globals.odbc_dsn = strdup(val);
...@@ -2680,6 +2683,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load) ...@@ -2680,6 +2683,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load)
memset(&globals, 0, sizeof(globals)); memset(&globals, 0, sizeof(globals));
globals.pool = pool; globals.pool = pool;
globals.dbname = CC_SQLITE_DB_NAME;
switch_core_hash_init(&globals.queue_hash, globals.pool); switch_core_hash_init(&globals.queue_hash, globals.pool);
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool); switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
...@@ -2773,6 +2778,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_callcenter_shutdown) ...@@ -2773,6 +2778,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_callcenter_shutdown)
} }
switch_safe_free(globals.odbc_dsn); switch_safe_free(globals.odbc_dsn);
switch_safe_free(globals.dbname);
switch_mutex_unlock(globals.mutex); switch_mutex_unlock(globals.mutex);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论