Re: IMAP: Why so MANY connections?



Hi Larry,

On 2001.07.23 20:42 Larry Rosenman wrote:
> I just started using Balsa (1.1.7) on FreeBSD, talking to my IMAP server
> at my house.  I noticed that BALSA seems to use one connection per FOLDER
> in the
> hierarchy.  WHY is this?  It seems wasteful.

IMAP is a stateful protocol. Each connection may be in SELECTED state, and
usually is. SELECT may take time to execute, depending on the server
implementation, RFC 2060 does not define a limit there.
Libmutt is written to open a new connection if no unselected connection is
available. On every folder open, the connection is selected to that folder
to read the header info. For performance reasons, it's not deselected but
stays selected for that folder, thereby blocking the connection for anything
other than retrieving messages from that folder.

If a test against some IMAP servers commonly used would reveal that SELECT
doesn't take a noticeable amount of time, libmutt may be changed to release
the connection after reading all headers, or multiplex a single connection
between all folders on a server. It is good practice in server programming
to cache all folder data on a per connection basis and use that cached data
when a folder is selected that has been opened before in the lifetime of the
connection. I believe all modern IMAP servers work this way. It may be safe
to make that change, but there is a price to pay: If 2 IMAP folders are
opened concurrently, the connection would probably need to be selected from
one mailbox to the other for each and every message header. Also, index
continuity may be jeopardized. It can't just simply be done by ignoring the
selected state, there probably needs to be a timeout of some sort, so if no
messages have been transferred on a selected connection for, say, 2 seconds,
the connection becomes available for use by other mailboxes.
That would result in 2-3 connections to be opened per server. Maybe.

Cheers,

Melanie




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]