[Imap-protocol] Concurrent flag changes
Timo Sirainen
tss at iki.fi
Thu May 3 10:26:58 PDT 2012
On 3.5.2012, at 17.07, Dave Cridland wrote:
> 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.
Yes, that was unintentional. I added the \Answered later while editing my mail and forgot to add it to S2 reply.
>> 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.
Like Arnt mentioned, if C1 and C2 are the connections from the same client, then a) really should be used. I realized it only later while sending my mail.
> 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.
If C1 and C2 are different independent clients, then there's not much of a conceptual difference between this and my b) behavior. It's all about the timing then - C2 might have sent it before C1's second STORE or it might have sent it during it. If there's less than a 1 second difference, no one can really say what happens, so I don't think it would be wrong for server to decide to behave a bit differently in such case.
More information about the Imap-protocol
mailing list