When the sqlite db is locked, retry up to ten times, sleeping one second between tries.

git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@375 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Pasi Kallinen 2007-12-27 23:44:09 +00:00
parent 46fbda0887
commit 56ba2a56b6
1 changed files with 10 additions and 4 deletions

View File

@ -1320,7 +1320,7 @@ userexist (char *cname, int isnew)
{
sqlite3 *db;
char *errmsg = NULL;
int ret;
int ret, retry = 10;
char *qbuf;
@ -1344,7 +1344,10 @@ userexist (char *cname, int isnew)
userexist_tmp_me = NULL;
}
ret = sqlite3_exec(db, qbuf, userexist_callback, 0, &errmsg);
do {
ret = sqlite3_exec(db, qbuf, userexist_callback, 0, &errmsg);
if (ret == SQLITE_BUSY) sleep(1);
} while ((ret == SQLITE_BUSY) && (retry-- > 0));
if (ret != SQLITE_OK) {
sqlite3_close(db);
@ -1540,7 +1543,7 @@ writefile (int requirenew)
{
sqlite3 *db;
char *errmsg = NULL;
int ret;
int ret, retry = 10;
char *qbuf;
char tmpbuf[32];
@ -1560,7 +1563,10 @@ writefile (int requirenew)
graceful_exit(107);
}
ret = sqlite3_exec(db, qbuf, NULL, NULL, &errmsg);
do {
ret = sqlite3_exec(db, qbuf, NULL, NULL, &errmsg);
if (ret == SQLITE_BUSY) sleep(1);
} while ((ret == SQLITE_BUSY) && (retry-- > 0));
sqlite3_free(qbuf);