Index: cdr/cdr_sqlite3_custom.c =================================================================== --- cdr/cdr_sqlite3_custom.c (revision 200468) +++ cdr/cdr_sqlite3_custom.c (working copy) @@ -304,6 +304,17 @@ return 0; } +static int database_busy_handler(void *userdata, int count) +{ + if (count > 5) { + return 0; + } + + usleep(200); + + return 1; +} + static int load_module(void) { char *error; @@ -331,6 +342,9 @@ return AST_MODULE_LOAD_DECLINE; } + /* Register a busy handler */ + sqlite3_busy_handler(db, database_busy_handler, NULL); + /* is the table there? */ sql = sqlite3_mprintf("SELECT COUNT(AcctId) FROM %q;", table); res = sqlite3_exec(db, sql, NULL, NULL, NULL);