1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Modifications to the way blocking locks are used in SQLITE_ENABLE_SETLK_TIMEOUT builds so that multiple processes or threads may not deadlock when operating on a single database.

FossilOrigin-Name: c516027d5fd876b7d0bf566435667d554db29ded30ad6fc1165caa4a93d015a0
This commit is contained in:
dan
2020-03-27 17:23:17 +00:00
parent 95b395901a
commit 97ccc1bd11
6 changed files with 79 additions and 18 deletions

View File

@@ -1569,9 +1569,21 @@ static int sqliteDefaultBusyCallback(
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
if( sqlite3OsFileControl(pFile,SQLITE_FCNTL_LOCK_TIMEOUT,&tmout)==SQLITE_OK ){
if( count ){
tmout = 0;
sqlite3OsFileControl(pFile, SQLITE_FCNTL_LOCK_TIMEOUT, &tmout);
return 0;
/* If this is the second or later invocation of the busy-handler,
** but tmout==0, then code in wal.c must have disabled the blocking
** lock before the SQLITE_BUSY error was hit. In this case, no delay
** occurred while waiting for the lock, so fall through to the xSleep()
** code below to delay a while before retrying the lock.
**
** Alternatively, if tmout!=0, then SQLite has already waited
** sqlite3.busyTimeout ms for a lock. In this case, return 0 to
** indicate that the lock should not be retried and the SQLITE_BUSY
** error returned to the application. */
if( tmout ){
tmout = 0;
sqlite3OsFileControl(pFile, SQLITE_FCNTL_LOCK_TIMEOUT, &tmout);
return 0;
}
}else{
return 1;
}