On Wed, 2003-07-16 at 22:53, Mark Crispin wrote:
> It is a reason to say "I don't want to have garbage-collection depend upon
> exclusive access."  If so, then you need a more complex mechanism than is
> used in UW imapd's mbx driver.

rename(). You rewrite the file and rename it over the old one. Next
synchronization check notices this and reopens the file.

Of course this may not be the fastest way if the file is large, which it
is when message bodies are stored into the file. I was mostly thinking
about index files while the actual message bodies would be stored
elsewhere.

This would require exclusive locking for all modifications though. I
kind of like the idea of being able to modify flags without any kind of
locks, but not at the cost of data loss (two clients setting flags for
same message simultaneously would lose the other change). Only way to
completely avoid that would be to use one byte per flag which is a bit
bloaty..

Then again, with fcntl locks it's possible to lock the file only
partially. So modifying flags for different messages would never block
on each others.

> First, you need to have some sort of share count on the "ghost" messages,
> so you know which ghosts are safe to purge.

Not a problem with rename().

> Second, you need to be able to purge a ghost without impacting other
> access.

Not a problem with rename() for read access.


Reply via email to