Ticket #2747 (closed defect: fixed)

Opened 22 months ago

Last modified 3 months ago

imap_keepalive ignored when less than timeout and too much idle

Reported by: rado Owned by: brendan
Priority: minor Milestone: 1.6
Component: IMAP Version: 1.5.13cvs (2007-01-09)
Keywords: patch Cc: jonathan.lamar.perkins@…

Description (last modified by brendan) (diff)

When you set "imap_keepalive" < IMAP-server-timeout < "timeout", then IMAP-server will disconnect when you let mutt idle for too long, despite imap_keepalive well within IMAP-server limit.

How-To-Repeat:

Set vars to values relative to each other per desc., then let mutt idle.

Change History

Changed 22 months ago by rado

Oops, ignore previous attachment:
1) forgot {} in keymap.c,

2) Probably mistake: too simplistic to extend imap_allow_reopen around buffy_checks,
so better add extra imap_allow/_disallow around km_dokey calling imap_keepalive.

Take this instead:

diff -ur org/curs_main.c cvs-2/curs_main.c
--- org/curs_main.c     Wed Aug 16 11:00:02 2006
+++ cvs-2/curs_main.c   Fri Feb  9 17:45:46 2007
@@ -513,7 +513,6 @@
     }

 #ifdef USE_IMAP
-    imap_keepalive ();
     imap_disallow_reopen (Context);
 #endif

@@ -602,7 +601,16 @@
       }
 #endif

+#ifdef USE_IMAP
+      imap_allow_reopen (Context);
+#endif
+
+/* imap_keepalive called in km_dokey, disallow after check. */
       op = km_dokey (MENU_MAIN);
+
+#ifdef USE_IMAP
+    imap_disallow_reopen (Context);
+#endif

       dprint(4, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, op));

diff -ur org/keymap.c cvs-2/keymap.c
--- org/keymap.c        Sat Sep 17 22:46:10 2005
+++ cvs-2/keymap.c      Fri Feb  9 17:54:47 2007
@@ -26,6 +26,9 @@
 #include "keymap.h"
 #include "mapping.h"
 #include "mutt_crypt.h"
+#ifdef USE_IMAP
+#include "imap/imap.h"
+#endif

 #include <stdlib.h>
 #include <string.h>
@@ -385,8 +388,15 @@
   FOREVER
   {
     /* ncurses doesn't return on resized screen when timeout is set to zero */
-    if (menu != MENU_EDITOR)
-      timeout ((Timeout > 0 ? Timeout : 60) * 1000);
+    if (menu != MENU_EDITOR) {
+      i=(Timeout > 0 ? Timeout : 60);
+
+#ifdef USE_IMAP
+    imap_keepalive ();
+       if ((ImapKeepalive > 0) && (ImapKeepalive < i)) i=ImapKeepalive;
+#endif
+      timeout (i * 1000);
+    }

     tmp = mutt_getch();

diff -ur org/menu.c cvs-2/menu.c
--- org/menu.c  Tue Jan  9 11:00:02 2007
+++ cvs-2/menu.c        Thu Feb  8 16:47:02 2007
@@ -853,10 +853,6 @@

     mutt_curs_set (0);

-#ifdef USE_IMAP
-    imap_keepalive ();
-#endif
-
     if (menu_redraw (menu) == OP_REDRAW)
       return OP_REDRAW;

diff -ur org/pager.c cvs-2/pager.c
--- org/pager.c Wed Aug 16 11:00:02 2006
+++ cvs-2/pager.c       Thu Feb  8 17:07:21 2007
@@ -1587,10 +1587,6 @@
   {
     mutt_curs_set (0);

-#ifdef USE_IMAP
-    imap_keepalive ();
-#endif
-
     if (redraw & REDRAW_FULL)
     {
       SETCOLOR (MT_COLOR_NORMAL);

Changed 20 months ago by brendan

  • owner changed from mutt-dev to brendan
  • priority changed from critical to minor
  • description modified (diff)
  • milestone set to 1.6

Changed 8 months ago by perkinjo

  • cc jonathan.lamar.perkins@… added

It looks like this comment is a proposed fix. I've downloaded the nightly tarball on 2008-04-05 and it looked like this patch was not applied.

Is there any particular reason it isn't applied?

Changed 8 months ago by brendan

  • reporter changed from regrado@… to rado

Changed 3 months ago by pdmef

  • keywords patch added

I'm just wondering why it isn't enough to just apply they keymap.c part of the patch, i.e. let all menus continue to handle keepalive on their own?

Changed 3 months ago by brendan

  • status changed from new to assigned

Changed 3 months ago by brendan

I like this patch - it means that other parts of the code no longer need special imap support, which is always nice. I'm committing it with minor edits. Sorry for taking so long, Rado.

Changed 3 months ago by Rado Smiljanic <regrado@…>

  • status changed from assigned to closed
  • resolution set to fixed

(In [4f67fc336986]) Make curses timeout the minimum of $timeout and $imap_keepalive. Do keepalive in km_dokey instead of directly in menu. Closes #2747.

Note: See TracTickets for help on using tickets.