forked from lix-project/lix
* Do a short sleep after SQLITE_BUSY.
This commit is contained in:
parent
b1eb252172
commit
c931a7aec5
|
@ -286,8 +286,7 @@ AC_CHECK_FUNCS([setresuid setreuid lchown])
|
||||||
|
|
||||||
|
|
||||||
# Nice to have, but not essential.
|
# Nice to have, but not essential.
|
||||||
AC_CHECK_FUNCS([strsignal])
|
AC_CHECK_FUNCS([strsignal posix_fallocate nanosleep])
|
||||||
AC_CHECK_FUNCS([posix_fallocate])
|
|
||||||
|
|
||||||
|
|
||||||
# This is needed if ATerm or bzip2 are static libraries,
|
# This is needed if ATerm or bzip2 are static libraries,
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
|
|
||||||
|
@ -35,6 +36,16 @@ static void throwSQLiteError(sqlite3 * db, const format & f)
|
||||||
int err = sqlite3_errcode(db);
|
int err = sqlite3_errcode(db);
|
||||||
if (err == SQLITE_BUSY) {
|
if (err == SQLITE_BUSY) {
|
||||||
printMsg(lvlError, "warning: SQLite database is busy");
|
printMsg(lvlError, "warning: SQLite database is busy");
|
||||||
|
/* Sleep for a while since retrying the transaction right away
|
||||||
|
is likely to fail again. */
|
||||||
|
#if HAVE_NANOSLEEP
|
||||||
|
struct timespec t;
|
||||||
|
t.tv_sec = 0;
|
||||||
|
t.tv_nsec = 100 * 1000 * 1000; /* 0.1s */
|
||||||
|
nanosleep(&t, 0);
|
||||||
|
#else
|
||||||
|
sleep(1);
|
||||||
|
#endif
|
||||||
throw SQLiteBusy(format("%1%: %2%") % f.str() % sqlite3_errmsg(db));
|
throw SQLiteBusy(format("%1%: %2%") % f.str() % sqlite3_errmsg(db));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue