#ASTERISK-23766 #close
Reported by: Igor Goncharovsky
Review: https://reviewboard.asterisk.org/r/3559/
........
Merged revisions 416336 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 416337 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 416338 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@416339
65c4cc65-6c06-0410-ace0-
fbb531ad65f3
int res = 0;
char *error = NULL;
char *sql = NULL;
- int count = 0;
if (db == NULL) {
/* Should not have loaded, but be failsafe. */
ast_free(value_string);
}
- /* XXX This seems awful arbitrary... */
- for (count = 0; count < 5; count++) {
- res = sqlite3_exec(db, sql, NULL, NULL, &error);
- if (res != SQLITE_BUSY && res != SQLITE_LOCKED) {
- break;
- }
- usleep(200);
- }
-
- if (error) {
+ if (sqlite3_exec(db, sql, NULL, NULL, &error) != SQLITE_OK) {
ast_log(LOG_ERROR, "%s. SQL: %s.\n", error, sql);
sqlite3_free(error);
}
free_config(0);
return AST_MODULE_LOAD_DECLINE;
}
-
+ sqlite3_busy_timeout(db, 1000);
/* is the table there? */
sql = sqlite3_mprintf("SELECT COUNT(AcctId) FROM %q;", table);
res = sqlite3_exec(db, sql, NULL, NULL, NULL);
{
char *error = NULL;
char *sql = NULL;
- int count = 0;
if (db == NULL) {
/* Should not have loaded, but be failsafe. */
ast_free(value_string);
}
- /* XXX This seems awful arbitrary... */
- for (count = 0; count < 5; count++) {
- int res = sqlite3_exec(db, sql, NULL, NULL, &error);
- if (res != SQLITE_BUSY && res != SQLITE_LOCKED) {
- break;
- }
- usleep(200);
- }
-
- ast_mutex_unlock(&lock);
-
- if (error) {
+ if (sqlite3_exec(db, sql, NULL, NULL, &error) != SQLITE_OK) {
ast_log(LOG_ERROR, "%s. SQL: %s.\n", error, sql);
sqlite3_free(error);
}
if (sql) {
sqlite3_free(sql);
}
+ ast_mutex_unlock(&lock);
return;
}
free_config();
return AST_MODULE_LOAD_DECLINE;
}
-
+ sqlite3_busy_timeout(db, 1000);
/* is the table there? */
sql = sqlite3_mprintf("SELECT COUNT(*) FROM %q;", table);
res = sqlite3_exec(db, sql, NULL, NULL, NULL);
ast_mutex_unlock(&dblock);
return -1;
}
+
ast_mutex_unlock(&dblock);
return 0;
char *errmsg = NULL;
int res =0;
- sqlite3_exec(astdb, sql, callback, arg, &errmsg);
- if (errmsg) {
- ast_log(LOG_WARNING, "Error executing SQL: %s\n", errmsg);
+ if (sqlite3_exec(astdb, sql, callback, arg, &errmsg) != SQLITE_OK) {
+ ast_log(LOG_WARNING, "Error executing SQL (%s): %s\n", sql, errmsg);
sqlite3_free(errmsg);
res = -1;
}
ao2_unlock(db);
return -1;
}
+ sqlite3_busy_timeout(db->handle, 1000);
if (db->debug) {
sqlite3_trace(db->handle, trace_cb, db);