Index: cdr/cdr_sqlite3_custom.c =================================================================== --- cdr/cdr_sqlite3_custom.c (revision 414121) +++ cdr/cdr_sqlite3_custom.c (working copy) @@ -228,7 +228,6 @@ int res = 0; char *error = NULL; char *sql = NULL; - int count = 0; if (db == NULL) { /* Should not have loaded, but be failsafe. */ @@ -264,15 +263,7 @@ 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); - } - + sqlite3_exec(db, sql, NULL, NULL, &error); if (error) { ast_log(LOG_ERROR, "%s. SQL: %s.\n", error, sql); sqlite3_free(error); @@ -315,7 +306,7 @@ 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); Index: cel/cel_sqlite3_custom.c =================================================================== --- cel/cel_sqlite3_custom.c (revision 414121) +++ cel/cel_sqlite3_custom.c (working copy) @@ -231,7 +231,6 @@ { char *error = NULL; char *sql = NULL; - int count = 0; if (db == NULL) { /* Should not have loaded, but be failsafe. */ @@ -266,17 +265,7 @@ 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); - + sqlite3_exec(db, sql, NULL, NULL, &error); if (error) { ast_log(LOG_ERROR, "%s. SQL: %s.\n", error, sql); sqlite3_free(error); @@ -285,6 +274,7 @@ if (sql) { sqlite3_free(sql); } + ast_mutex_unlock(&lock); return; } @@ -319,7 +309,7 @@ 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); Index: main/db.c =================================================================== --- main/db.c (revision 414121) +++ main/db.c (working copy) @@ -257,6 +257,7 @@ ast_mutex_unlock(&dblock); return -1; } + sqlite3_busy_timeout(astdb, 1000); ast_mutex_unlock(&dblock); return 0; Index: res/res_config_sqlite3.c =================================================================== --- res/res_config_sqlite3.c (revision 414121) +++ res/res_config_sqlite3.c (working copy) @@ -315,6 +315,7 @@ ao2_unlock(db); return -1; } + sqlite3_busy_timeout(db->handle, 1000); if (db->debug) { sqlite3_trace(db->handle, trace_cb, db);