Mark Spiegel wrote:
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?
I have a similar question. I, too, am writing a VFS to port SQLite 3.5.x to an embedded OS, and am trying to figure out how to implement xLock(), xUnlock(), and xCheckReservedLock(). My target OS doesn't have any file locking primitives, so I intend to implement the locking using a hash table of fileLock nodes [similar to unixLock()] and a lockType field in the file descriptor. I am thinking of writing xLock() so that it handles *all possible* locking transitions, regardless of whether or not they will actually occur in practice: UNLOCKED -> SHARED UNLOCKED -> RESERVED UNLOCKED -> PENDING UNLOCKED -> EXCLUSIVE SHARED -> RESERVED SHARED -> PENDING SHARED -> EXCLUSIVE RESERVED -> PENDING RESERVED -> EXCLUSIVE PENDING -> EXCLUSIVE For example, if a database file is UNLOCKED, and an attached process wants to go from UNLOCKED straight to EXCLUSIVE, it seems perfectly safe to let him do it, even though the doc- umentation states that a process wanting an EXCLUSIVE lock always acquires a SHARED lock first. In other words, I am thinking of coding xLock() so that it allows all legal transitions (and disallows all illegal ones), but has no knowledge of the pager's policies regarding trans- itions. That is, I want a strict separation between OS-level policies (what is legal from the point of view of the lock state defin- itions) and pager-level policies (what is actually done in practice). Does this seem like a reasonable idea? More importantly, will it work (not break SQLite)? Thanks, Richard Klein
----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------