mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 11:06:31 +00:00
Sqlite3: make busy_timeout configurable.
Enables runtime configuration of busy_timeout for sqlite databases. Default timeout remains 1000ms. ASTERISK-27014 #close Change-Id: I8921a3aac3c335843be4cb17d2dd0a5c157a36da
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user