summaryrefslogtreecommitdiff
path: root/cel
diff options
context:
space:
mode:
authorMartin Tomec <tomec.martin@gmail.com>2017-05-23 18:07:53 +0200
committerMartin Tomec <tomec.martin@gmail.com>2017-05-25 10:02:42 +0200
commit44c5a144ce3194fb9cec02f42436d93853b33a86 (patch)
treefbcf4a29a26400cf73785785d4479a71fbe2d31d /cel
parentdece2eb8929c11bad30616d8f3a236ed449c718c (diff)
Sqlite3: make busy_timeout configurable.
Enables runtime configuration of busy_timeout for sqlite databases. Default timeout remains 1000ms. ASTERISK-27014 #close Change-Id: I8921a3aac3c335843be4cb17d2dd0a5c157a36da
Diffstat (limited to 'cel')
-rw-r--r--cel/cel_sqlite3_custom.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/cel/cel_sqlite3_custom.c b/cel/cel_sqlite3_custom.c
index 6075b8a2b..5675da6b3 100644
--- a/cel/cel_sqlite3_custom.c
+++ b/cel/cel_sqlite3_custom.c
@@ -68,6 +68,7 @@ static char table[80];
* \bug Handling of this var is crash prone on reloads
*/
static char *columns;
+static int busy_timeout;
struct values {
char *expression;
@@ -187,6 +188,15 @@ static int load_config(int reload)
strcpy(table, "cel");
}
+ /* sqlite3_busy_timeout in miliseconds */
+ if ((tmp = ast_variable_retrieve(cfg, "master", "busy_timeout")) != NULL) {
+ if (ast_parse_arg(tmp, PARSE_INT32|PARSE_DEFAULT, &busy_timeout, 1000) != 0) {
+ ast_log(LOG_WARNING, "Invalid busy_timeout value '%s' specified. Using 1000 instead.\n", tmp);
+ }
+ } else {
+ busy_timeout = 1000;
+ }
+
/* Columns */
if (load_column_config(ast_variable_retrieve(cfg, "master", "columns"))) {
ast_config_destroy(cfg);
@@ -306,7 +316,7 @@ static int load_module(void)
free_config();
return AST_MODULE_LOAD_DECLINE;
}
- sqlite3_busy_timeout(db, 1000);
+ sqlite3_busy_timeout(db, busy_timeout);
/* is the table there? */
sql = sqlite3_mprintf("SELECT COUNT(*) FROM %q;", table);
res = sqlite3_exec(db, sql, NULL, NULL, NULL);