mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-19 03:07:59 +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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user