Is there a race condition in IMAP's idle-searc

2019-07-19 00:39发布

I have a bunch of code that does IMAP commands “search, idle, done, search, idle, done, search, ...”.

Is it possible that some messages arrive between search and idle commands and, thus, will only be received by that code after the idle return / timeout?

EDIT1: I tried it with GMail: tested with sleep 60 between the message-processing and IDLE, and IDLE didn't return before timeout even though there were messages; to make sure I didn't miss an event from IDLE, I did a clientside send/recv dump and tried an additional read() before the sending of IDLE after the sleep(); while sending test messaged during the sleep().

EDIT2: Using two connections, one for getting the mail (using 'SEARCH') and another for using IDLE to get instant 'there are new messages' events, avoids the race condition, but someone claims there are some problems with that.

标签: imap
1条回答
ら.Afraid
2楼-- · 2019-07-19 01:33

   
A properly implemented server will notify you of the new messages as soon as you start IDLE, if it hasn't already notified you about them in response to some other command.

查看更多
登录 后发表回答