]> granicus.if.org Git - neomutt/commitdiff
Avoid a possible race when entering the IDLE command - if new mail notification
authorBrendan Cully <brendan@kublai.com>
Mon, 19 Dec 2005 17:37:35 +0000 (17:37 +0000)
committerBrendan Cully <brendan@kublai.com>
Mon, 19 Dec 2005 17:37:35 +0000 (17:37 +0000)
is received before the + response, mutt may attempt to send a fetch command
before it realises it's idling.

imap/imap.c

index 9f685e7dedbc34d12f84cadcf8623aa433e85a15..fc9b57484e9a6bacabb364e58c7d74b09c5917ff 100644 (file)
@@ -1261,15 +1261,16 @@ int imap_check_mailbox (CONTEXT *ctx, int *index_hint, int force)
           || force || time(NULL) >= idata->lastread + ImapKeepalive))
   {
     imap_cmd_start (idata, "IDLE");
+    idata->state = IMAP_IDLE;
     do
       result = imap_cmd_step (idata);
     while (result == IMAP_CMD_CONTINUE);
     if (result != IMAP_CMD_RESPOND)
     {
       dprint (1, (debugfile, "Error starting IDLE\n"));
+      idata->state = IMAP_SELECTED;
       return -1;
     }
-    idata->state = IMAP_IDLE;
   }
   if (idata->state == IMAP_IDLE)
   {