1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Add the sqlite3_setlk_timeout() API. For setting the timeout used by SQLITE_ENABLE_SETLK_TIMEOUT blocking locks without also setting the regular retry-based busy-timeout.

FossilOrigin-Name: 4a7eb492797abb47b18b7dfc557aeae43a0dea5b861efc203398d5059b10d131
This commit is contained in:
dan
2025-01-27 11:50:03 +00:00
parent 2539fb2bc5
commit 43aad25b1b
8 changed files with 164 additions and 13 deletions

View File

@@ -1766,6 +1766,9 @@ int sqlite3_busy_handler(
db->busyHandler.pBusyArg = pArg;
db->busyHandler.nBusy = 0;
db->busyTimeout = 0;
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
db->setlkTimeout = 0;
#endif
sqlite3_mutex_leave(db->mutex);
return SQLITE_OK;
}
@@ -1815,12 +1818,25 @@ int sqlite3_busy_timeout(sqlite3 *db, int ms){
sqlite3_busy_handler(db, (int(*)(void*,int))sqliteDefaultBusyCallback,
(void*)db);
db->busyTimeout = ms;
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
db->setlkTimeout = ms;
#endif
}else{
sqlite3_busy_handler(db, 0, 0);
}
return SQLITE_OK;
}
int sqlite3_setlk_timeout(sqlite3 *db, int ms){
#ifdef SQLITE_ENABLE_API_ARMOR
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
#endif
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
db->setlkTimeout = (ms>0 ? ms : 0);
#endif
return SQLITE_OK;
}
/*
** Cause any pending operation to stop at its earliest opportunity.
*/