Hello Ara,
On 2 ago 2004, at 9:59, Ara.T.Howard wrote:
the simplest way to do this is to create a
file for each db, say db.lock, and to apply a blocking read/write to this file
depending on the intent of your operation. the contents of this file are not
important - it is merely used as a mutex that processes can coordinate access
to the database with. the key is to ask for the locks in a blocking fashion -
this should ensure that only one process is accessing the database at a given
moment and prevent sqlite from ever needing to return 'database is locked'.
A word of caution to Mac OS X SQLiters. The following statement applies to Jaguar (Mac OS X 10.2) and earlier. I'm not sure it it's still the case with Panther (10.3) and Tiger (10.4) though:
Creating a file is not an atomic operation and may produce a race condition if two or more processes attempt to create such lock file at the same time, on the same place. The solution in this case is to create a directory instead. Using this route, there won't be race conditions.
There is a small performance hit, but considering that a file lock may cause you trouble, I would think that it's better to bite the bullet and go for the safest solution.
Again, I'm not sure this applies to Panther or Tiger.
Regards,
-- Tito
smime.p7s
Description: S/MIME cryptographic signature