Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a race condition in IMAP's idle-search-idle?

Tags:

imap

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.

like image 828
HoverHell Avatar asked Dec 12 '25 21:12

HoverHell


1 Answers

   
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.

like image 160
Max Avatar answered Dec 16 '25 22:12

Max



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!