On Wed, 16 Jul 2003, Timo Sirainen wrote: > Shared mailboxes are exactly where I was thinking this read-lockless > store would work very well. You never have to wait for locks when > you're reading the store, and more importantly you never have to wait > for readers to finish before you get a write lock.
On a much simpler level, the locking strategy used by the mbx format in UW imapd is this: There is no read lock. There is a shared access lock. This lock is acquired at open time, and thus is blocked only if the access lock is held exclusive. As a consequence, you never have to wait for locks when reading the store. Writes to flags do not acquire any locks. It is assumed that the write is atomic. No attempt is made to guard against a timing race between the read of flags and the update of new flags, although a time is made to minimize the vulnerable period. Expunge requires exclusive acquisition of the access lock. Should this be achieved, opens are blocked until the expunge finishes. Otherwise, the expunged messages are marked with an internal flag (not visible to the client) that the message is to be expunged. Such messages become "ghost" messages, as described in RFC 2180 4.1.1 (which as far as I am concerned is the only correct implementation). Of course, any expunge under exclusive acquisition of the access lock also purges the "ghosts". If a checkpoint discovers that it can acquire exclusive acquisition of the access lock, it will also do so and purge the "ghosts" but not expunge deleted messages. In summary, the only locking is to purge expunged messages; and the only impact of the lock is on open. -- Mark -- http://staff.washington.edu/mrc Science does not emerge from voting, party politics, or public debate. Si vis pacem, para bellum.