forked from Mirrors/freeswitch
add retry on lock to core sql func
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6505 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
26fccbdddb
commit
b6f7b354f2
@ -79,7 +79,22 @@ SWITCH_DECLARE(const char *) switch_core_db_errmsg(switch_core_db_t *db)
|
||||
|
||||
SWITCH_DECLARE(int) switch_core_db_exec(switch_core_db_t *db, const char *sql, switch_core_db_callback_func_t callback, void *data, char **errmsg)
|
||||
{
|
||||
return sqlite3_exec(db, sql, callback, data, errmsg);
|
||||
int ret;
|
||||
int sane = 100;
|
||||
|
||||
while(--sane > 0) {
|
||||
ret = sqlite3_exec(db, sql, callback, data, errmsg);
|
||||
|
||||
if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) {
|
||||
switch_safe_free(*errmsg);
|
||||
switch_yield(1000);
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(int) switch_core_db_finalize(switch_core_db_stmt_t *pStmt)
|
||||
|
Loading…
Reference in New Issue
Block a user