MBOX-Line: From dave at cridland.net  Thu May  3 07:07:15 2012
To: imap-protocol@u.washington.edu
From: Dave Cridland <dave@cridland.net>
Date: Fri Jun  8 12:34:48 2018
Subject: [Imap-protocol] Concurrent flag changes
In-Reply-To: <14DB8F84-E3D5-426A-BBF6-5B4746B6E3DF@iki.fi>
References: <14DB8F84-E3D5-426A-BBF6-5B4746B6E3DF@iki.fi>
Message-ID: <7596.1336054035.886533@puncture>

On Wed May  2 22:28:46 2012, Timo Sirainen wrote:
> C1: a FETCH 1 FLAGS
> S1: * 1 FETCH (FLAGS (\Seen \Answered))
> S1: a OK
> 
> C2: b STORE 1 +FLAGS (\Flagged)
> S2: * 1 FETCH (FLAGS (\Seen \Flagged))
> S2: b OK
> 
> 
I think S2's response here is wrong - specifically, I can't see why  
the server shouldn't respond including \Answered from the first  
session. But I admit that very close concurrency might make that hard  
- though really, I'd find that worrying - I expect flag changes to be  
atomic.

> At this point C1 still thinks that 1's flags are (\Seen), and being  
> a little bit stupid it unsets the \Seen flag by sending:
> 
> C1: c STORE 1 FLAGS (\Answered)

That's very stupid. It's not said "Remove \Seen", it's said "Set the  
flags to these".

> S1: * 1 FETCH (FLAGS (\Answered))
> S1: * 1 FETCH (FLAGS (\Answered \Flagged))
> 
> Dovecot currently sends the first reply, but I've started thinking  
> that perhaps I should change it to the second one. The question is  
> really: Should STORE FLAGS be thought of as
> 
> a) Reset all the flags that you have currently, whatever they are,  
> and only set these flags.

Only ever this. Anything else strikes me as fundamentally wrong.

If it responds with the second reply, I'd take that to mean that some  
other client had set \Flagged, between the server acting on my set,  
and before it responded. Surprising, but I'd cope.

Dave.
-- 
Dave Cridland - mailto:dave@cridland.net - xmpp:dwd@dave.cridland.net
  - acap://acap.dave.cridland.net/byowner/user/dwd/bookmarks/
  - http://dave.cridland.net/
Infotrope Polymer - ACAP, IMAP, ESMTP, and Lemonade

