While working on a VFS for use in 3.5.1, I was looking at the winLock()
and have a question.
Is it possible for the lock on a winFile object to progress from
SHARED_LOCK to EXCLUSIVE_LOCK without first acquiring a RESERVED_LOCK?
Assuming that it is, it seems that the comments at the start of the
function are at odds with the implementation a little bit. The comments
indicate that a PENDING_LOCK will be an intermediate state between a
SHARED_LOCK and EXCLUSIVE_LOCK. This would make sense based on the
other SQLITE docs I've read. However, as I read the code it would seem
that a SHARED_LOCK is not acquired if proceeding from a SHARED_LOCK to
EXCLUSIVE_LOCK. The PENDING_LOCK is only acquired if the current lock
type is NO_LOCK or the current lock type is RESERVED_LOCK and an
EXCLUSIVE_LOCK is desired.
The reason I'm asking is that later in the function where the
EXCLUSIVE_LOCK is acquired, the SHARED_LOCK is released before trying to
acquire the EXCLUSIVE_LOCK. Without the protection of the PENDING_LOCK,
it seems there is a race condition here where a winFile object may think
it has tried (and possibly failed) to promote a SHARED_LOCK to an
EXCLUSIVE_LOCK without realizing that at least once, and possibly twice,
it was in a state where it held no lock at all.
I apologize in advance if I've misread the code.
Thanks in advance...
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------