MBOX-Line: From mrc at CAC.Washington.EDU  Tue Sep 19 08:58:03 2006
To: imap-protocol@u.washington.edu
From: Mark Crispin <mrc@CAC.Washington.EDU>
Date: Fri Jun  8 12:34:38 2018
Subject: [Imap-protocol] Avoiding connection-loss
In-Reply-To: <+zIRTx+YE8iB3/J6OY9jzQ.md5@libertango.oryx.com>
References: <009901c6daf1$1026f580$2d65a8c0@ProImage.local> 
	<Pine.OSX.4.64.0609180815470.368@pangtzu.panda.com>
	<5273.1158594140.711631@invsysm1>
	<Pine.OSX.4.64.0609180855530.368@pangtzu.panda.com> 
	<KKoUp6qRrcfZ2zeBmqURBg.md5@libertango.oryx.com> 
	<Pine.OSX.4.64.0609181137520.368@pangtzu.panda.com>
	<+zIRTx+YE8iB3/J6OY9jzQ.md5@libertango.oryx.com>
Message-ID: <Pine.OSX.4.64.0609190849330.368@pangtzu.panda.com>

On Tue, 19 Sep 2006, Arnt Gulbrandsen wrote:
>>    [...] clients using IDLE are advised to terminate the IDLE and
>>    re-issue it at least every 29 minutes to avoid being logged off.
>> You like cutting things that close?
> Yes. In my professional capacity I need to add workarounds and so on. 
> Privately I like to follow the protocol and expect the other guy to do the 
> same.

That wasn't the point.  Allowing an IDLE to go on for 29 minutes and 50 
seconds poses a terrible risk of losing the race with only 10 seconds of 
leeway.

> No. MSN/UID arithmetic. The following sequence is somewhat contrived, but 
> it's short and I expect you get the idea:
> S: * 1000 EXISTS
> S: * OK [UIDNEXT 2001]
> S: * 1001 EXISTS
> S: * 1001 EXPUNGE
> S: * 1001 EXISTS
> C: a UID FETCH 2002 ENVELOPE
> There is fallback code to handle unexpected UIDNEXT increases, but not 
> decreases.

There's a problem with your example.  UIDNEXT is only sent at SELECT time. 
It is not sent during UID FETCH or other routine operations.  Also, 
there's no reason to believe that that UID FETCH would work; UIDNEXT is 
only a prediction and not a promise.

So you can only be affected if you
  (1) keep a mathematical calculation of minimum UIDNEXT as a result of
      EXISTS
  (2) use that calculation between sessions.

> 1. Your server is the reference implementation. As I understand it, a 
> reference implementation is one that implements the protocol completely, 
> accurately, meticulously, and above all, without dubious hacks.

It would be easy to achieve this.  Elect me Dictator of the World, so I 
can outlaw broken IMAP clients that make such kludges necessary!!  As 
Dictator of the World, I promise a world of only perfect IMAP!  ;-)

Of course, there's the small problem that, like Koko in Gilbert & 
Sullivan's "The Mikado", "I have a little list"... ;-)

> But wouldn't it be better to extend the 30-minute timeout than to throw a 
> spanner in the works of clients that do MSN/UID arithmetic?

I might extend the timeout to 32 minutes if I had evidence that certain 
broken clients wouldn't screw up in other ways.

But the question is if any client is actually affected.  As noted above, 
UIDNEXT is only sent at SELECT time.

-- 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.

