Re: Multiple IMAP connections to same folder
- From: Aaron Carlow <acarlow@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 30 Dec 2005 23:13:35 -0800
Mark Crispin wrote:
I don't think that you fully understand the problem. Suppose the file opening, operations, and closing are done by a subroutine library that your application calls. From the point of view of the application, the subroutine library is a black box; it doesn't necessarily know what the subroutine library does. This characteristic of fcntl() requires that the application know what the subroutine library does.
Ok, I see the implications here much better now.
It gets worse. Thanks to links, files can be accessed through multiple names. So, an application may not know that fileA and fileB are really the same file. So the application may have to keep a table of all open files with their device and inode numbers, and prior to opening any file, check to see if it's open by that name.
Here's what typically happens in an IMAP server. The client has a mailbox open. Since it's open, it has a shared lock open on the mailbox on the server. Now, the client uploads a message; the upload operation supplies the name of the destination mailbox and there is no requirement that it be the same mailbox that is open. So it opens another descriptor append the message to the destination, keeping the first descriptor for the open mailbox.
But suppose it is the same mailbox. It now has two descriptors open on the same file, and then when the upload finishes the second descriptor (which never locked, because it was just appending) is closed. That kills the lock on the first descriptor. That in turn allows some other session to open and lock the mailbox, and maybe do things like expunge it even though the first session still has it open...oh dear, oh my.
Now it's all making sense.
The way I put it, having combination locks and electronic safeties on guns sounds like a real good idea...until you're in a gunfight and your gun won't go bang when you want it to...
An example which I both clearly understand and agree with.
That at least explains to some extent why we find ourselves in this predicament.Any sort of database would use locks.
Most of the traditional mail applications were very primitive and never attempted to provide multiple simultaneous access, much less multiple simultaneous read/write access. Instead, they just prevented mail delivery (e.g., from sendmail) and a single mail reader from stepping on each other; and if a user ran two mail readers at a time, he "deserved" having his mail corrupted.
[In fact, I very much remember being told in the late 1980s that multiple simultaneous access to mail was "impossible" on UNIX and that I shouldn't even think of such a bizarre concept.]
I now understand why so many people have talked about Maildir as being "safer" -- because locking support is woefully inadequate on certain platforms and Maildir to some extent sidesteps the problem. In this context, solutions such as Maildir seem to address the symptoms of the disease rather than to treat it. That's not meant as a criticism of Maildir as much as an observation of the current state of affairs.And if this is as serious as you seem to indicate, I wonder why there isn't more of an uproar from the Linux application developers?
Some programmers have squawked about it!
Other programmers have given up on having good lock support in UNIX and UNIX like systems, and consequently resort to other means to accomplish the synchronization that they need.
For example, the oft-touted Maildir format is often claimed not to use locks at all; and its proponents claim this to be a benefit. Actually it does; but these locks are kernel-internal locks inside the filesystem. Maildir application code doesn't do any locking itself.
Windows does have good lock support. I wouldn't be surprised if the evil empire uses this as a selling point for Windows. Traditional operating systems, such as OS/360, TOPS-10/20, VAX/VMS, Unisys, etc. (pretty much anything that ever had COBOL applications!) also had good lock support. It's pretty likely that your paycheck is still printed by some ancient operating system.Wow I find this all rather fascinating if disappointing. Fortunately, I use FreeBSD for the most part so this doesn't affect me directly. However, since a programmer would likely have portability in mind, it indirectly affects any UNIX/UNIX-like OS as you have already stated. Sadly, if Linux is missing the boat on this then we all will most likely be dealing with the consequences one way or another as programmers are forced to come up with their own solutions to the problem.
Thanks so much for taking the time to explain all this. I can't be the only layman to have wondered and suffered his/her curiosity in silence.
Aaron Carlow .
- References:
- Multiple IMAP connections to same folder
- From: Jaime
- Re: Multiple IMAP connections to same folder
- From: Jonathan Abbey
- Re: Multiple IMAP connections to same folder
- From: Mark Crispin
- Re: Multiple IMAP connections to same folder
- From: Jonathan Abbey
- Re: Multiple IMAP connections to same folder
- From: Mark Crispin
- Re: Multiple IMAP connections to same folder
- From: Aaron Carlow
- Re: Multiple IMAP connections to same folder
- From: Mark Crispin
- Re: Multiple IMAP connections to same folder
- From: Aaron Carlow
- Re: Multiple IMAP connections to same folder
- From: Mark Crispin
- Re: Multiple IMAP connections to same folder
- From: Aaron Carlow
- Re: Multiple IMAP connections to same folder
- From: Mark Crispin
- Multiple IMAP connections to same folder
- Prev by Date: Re: Multiple IMAP connections to same folder
- Next by Date: Re: Multiple IMAP connections to same folder
- Previous by thread: Re: Multiple IMAP connections to same folder
- Next by thread: Re: Multiple IMAP connections to same folder
- Index(es):
Relevant Pages
|