In imap_check_mailbox(), there is an if clause where we potentially poll
IMAP with a NOOP command. This can be invoked on many ops, including if
we e.g. move to the next message on the index. According to
http://www.mutt.org/doc/manual/#timeout, the expected behavior of
Timeout is that a timeout value of <= 0 will cause Mutt to never time
out. We're not accounting for this in this if check, so setting timeout
to 0 will cause this NOOP command to be sent all the time, which is the
opposite of what the user wants.

Instead, add a check for Timeout > 0. Doing this makes my mutt instance
going from almost being completely unusable in the pager due to
latencies on almost every command, to much more seamless.

Signed-off-by: David Vernet <v...@manifault.com>
---
 imap/imap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/imap/imap.c b/imap/imap.c
index b92c2dcfbccd..bba49b1a7a5f 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -1804,7 +1804,8 @@ int imap_check_mailbox (CONTEXT *ctx, int *index_hint, 
int force)
   }
 
   if ((force ||
-       (idata->state != IMAP_IDLE && time(NULL) >= idata->lastread + Timeout))
+       (idata->state != IMAP_IDLE &&
+        Timeout > 0 && time(NULL) >= idata->lastread + Timeout))
       && imap_exec (idata, "NOOP", IMAP_CMD_POLL) != 0)
     goto errcleanup;
 
-- 
2.38.0

Reply via email to