diff options
author | Martin Tomec <tomec.martin@gmail.com> | 2017-05-23 18:07:53 +0200 |
---|---|---|
committer | Martin Tomec <tomec.martin@gmail.com> | 2017-05-25 10:02:42 +0200 |
commit | 44c5a144ce3194fb9cec02f42436d93853b33a86 (patch) | |
tree | fbcf4a29a26400cf73785785d4479a71fbe2d31d /cdr/cdr_sqlite3_custom.c | |
parent | dece2eb8929c11bad30616d8f3a236ed449c718c (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 'cdr/cdr_sqlite3_custom.c')
-rw-r--r-- | cdr/cdr_sqlite3_custom.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/cdr/cdr_sqlite3_custom.c b/cdr/cdr_sqlite3_custom.c index e8d763edd..2212d0499 100644 --- a/cdr/cdr_sqlite3_custom.c +++ b/cdr/cdr_sqlite3_custom.c @@ -61,6 +61,7 @@ static sqlite3 *db = NULL; static char table[80]; static char *columns; +static int busy_timeout; struct values { AST_LIST_ENTRY(values) list; @@ -181,6 +182,15 @@ static int load_config(int reload) strcpy(table, "cdr"); } + /* 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); @@ -305,7 +315,7 @@ static int load_module(void) free_config(0); 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(AcctId) FROM %q;", table); res = sqlite3_exec(db, sql, NULL, NULL, NULL); |