MBOX-Line: From mrc+imap at panda.com  Fri May 27 09:24:54 2011
To: imap-protocol@u.washington.edu
From: Mark Crispin <mrc+imap@panda.com>
Date: Fri Jun  8 12:34:46 2018
Subject: [Imap-protocol] History question.
In-Reply-To: <3054.1306482625.167799@puncture>
References: <4DDEA412.6030305@aol.com> <4DDEDDD6.1040507@logicprobe.org>
	<alpine.BSO.2.00.1105261628370.892@morgaine.smi.sendmail.com>
	<2CB073A1-B421-4CFB-AE30-B17005C876A0@iki.fi>
	<alpine.OSX.2.00.1105261724000.973@hsinghsing.panda.com>
	<4DDF06A9.2050608@logicprobe.org>
	<alpine.OSX.2.00.1105262030000.973@hsinghsing.panda.com>
	<3054.1306482625.167799@puncture>
Message-ID: <alpine.OSX.2.00.1105270901270.973@hsinghsing.panda.com>

On Fri, 27 May 2011, Dave Cridland wrote:
>> I would also reform IMAP's Hollerith strings (literals) to send the
>> entire command first (thus one complete line) and then the string
>> payloads.
> I'm not following the motivation for this. Parse a token at a time
> off the wire until you find a CRLF token - seems simple enough to me.
> It's not as if anyone uses fgets to parse anyway. What am I missing?

The switch in modality between line and sized buffer in commands turns out
to be a problem in some server frameworks, particularly if multiple
literals appear in the same command.  A related issue is that you need to
read the literals before you know that the command is syntactically valid
and can be done.

Consider a framework in which you only get a thread at I/O complete
events, the thread is given up when it goes into I/O wait, and you get a
different thread each time.  You have to save complete, increasingly
complex, context at each mode switch for a state machine.  You can't rely
upon implied code state in the parser, which is the obvious way to handle
literals and what UW/Panda imapd do.

MULTIAPPEND and CATENATE are particularly extreme examples.

Literals done as I suggest wouldn't be particularly hard for the lexical
token-at-a-time parser; you just build a list of literals to fill in, then
fill them in.  It would be a lifesaver in cases where it's really painful
to break the parse across multiple threads.  [Guess who had to implement
an IMAP server in such an environment.]

If I could take a time machine and change one, but only one, thing in the
basic design of IMAP, this would be it.

-- Mark --

http://panda.com/mrc
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.

