dimanche 27 décembre 2015

SQLite - Open an EXCLUSIVE connection, fallback to SHARED on failure

I'm trying to create a 'fallback' mechanism, which will allow a process to gain EXCLUSIVE lock on a db file, and if it fails - gain a SHARED [=readonly] lock.

The idea is that once a process gains an EXCLUSIVE lock, it will write some information about itself in one of the tabels, so once another process tries to gain an EXCLUSIVE lock - it will fail, but will be able to perform 'SELECT' queries on the db.

I found the following question, which only describes half the answer - i'm able to gain 'EXCLUSIVE' lock, but I didn't find a way to gain a 'SHARED' lock.

Aucun commentaire:

Enregistrer un commentaire