help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gnus slow with IMAP when changing ISP's


From: Stefan Monnier
Subject: Re: Gnus slow with IMAP when changing ISP's
Date: Thu, 19 Nov 2009 11:29:05 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

> I use gnus from work and from home. I have a different ISP in each
> place. When I start gnus from one of those places (say home) I can
> access my IMAP account almost right away, however, if I go to the
> other place (my work) checking for new mail takes forever.

By "forever" do you mean that it is slow, or that it really literally
never terminates (i.e. it doesn't work at all)?

I see a similar problem, but in my case it's not just slow, Gnus just
sits there and never terminates.  It looks like the problem has to with
NAT and/or with going from one private subnet to another and/or changing
IP address.  In any case what I see happen is that the underlying
connection is stuck and doesn't timeout and Gnus's imap backend doesn't
have its own timeout to make up for it.

For what it's worth, I've been using the patch below, so that I just hit
C-g when the connection is stuck, and then retry the command which causes
the connection to be re-created from scratch and everything works
fine again.


        Stefan


--- imap.el.~1.21.~     2009-09-28 09:00:51.000000000 -0400
+++ imap.el     2009-11-19 11:28:18.000000000 -0500
@@ -1313,7 +1313,8 @@
     imap-namespace))
 
 (defun imap-send-command-wait (command &optional buffer)
-  (imap-wait-for-tag (imap-send-command command buffer) buffer))
+  (with-local-quit            ; See backtrace in imap-accept-process-output.
+    (imap-wait-for-tag (imap-send-command command buffer) buffer)))
 
 (defun imap-logout (&optional buffer)
   (or buffer (setq buffer (current-buffer)))
@@ -2029,6 +2030,61 @@
          (imap-send-command-1 cmdstr))
       tag)))
 
+(defun imap-accept-process-output (proc &rest args)
+  ;; FIXME: This is sometimes called with quit inhibited:
+  ;; Tried to fix it with a `with-local-quit' in imap-send-command-wait.
+  ;; Debugger entered--Lisp error: (error "Blocking call to 
accept-process-output with quit inhibited!!")
+  ;;   accept-process-output(#<process imap> 0 100 nil)
+  ;;   apply(accept-process-output #<process imap> (0 100))
+  ;;   byte-code("\302\303    #\207" [proc args apply accept-process-output] 
4)
+  ;;   imap-accept-process-output(#<process imap> 0 100)
+  ;;   imap-wait-for-tag(1937 nil)
+  ;;   imap-send-command-wait("SELECT \"inbox\"")
+  ;;   imap-mailbox-select-1("inbox" nil)
+  ;;   imap-mailbox-select("inbox")
+  ;;   nnimap-possibly-change-group("inbox" "diro")
+  ;;   nnimap-request-article-part(36260 "BODY.PEEK[]" BODYDETAIL "inbox" 
"diro" nil detail)
+  ;;   nnimap-request-article(36260 "inbox" "diro" nil)
+  ;;   gnus-request-article(36260 "nnimap+diro:inbox")
+  ;;   gnus-async-prefetch-article("nnimap+diro:inbox" t #<buffer *Summary 
nnimap+diro:inbox*> t)
+  ;;   gnus-async-article-callback(t "nnimap+diro:inbox" 36261 #<marker at 
12447484 in  *Async Prefetch Article*> #<buffer *Summary nnimap+diro:inbox*> t)
+  ;;   (lambda (arg) (gnus-async-article-callback arg "nnimap+diro:inbox" 
36261 #<marker at 12447484 in  *Async Prefetch Article*> #<buffer *Summary 
nnimap+diro:inbox*> t))(t)
+  ;;   nnimap-callback(36261 (lambda (arg) (gnus-async-article-callback arg 
"nnimap+diro:inbox" 36261 #<marker at 12447484 in  *Async Prefetch Article*> 
#<buffer *Summary nnimap+diro:inbox*> t)) #<buffer  *Async Prefetch Article*>)
+  ;;   (lambda nil (nnimap-callback 36261 (lambda ... ...) #<buffer  *Async 
Prefetch Article*>))()
+  ;;   run-hooks(imap-fetch-data-hook)
+  ;;   imap-parse-fetch(6731)
+  ;;   imap-parse-response()
+  ;;   imap-arrival-filter(#<process imap> "evaluated the resulting lisp. The 
lisp looks like this:
\n
\n(fset 'findwordfile
\n   (lambda (&optional arg) \"Keyboard macro.\" (interactive \"p\")
\n(kmacro-exec-ring-item (quote (\"=13file\" 0 \"%d\")) arg)))
\n
\nWhen trying to use the macro, I get this in my minibuffer:
\n
\nfindwordfile: Symbol's function definition is void: kmacro-exec-ring-item
\n
\nIf I put (require 'kmacro) at the beginning of my file containing
\nmacros it works.
\n
\nIs there a missing autoload before this line?
\n(defun kmacro-exec-ring-item (item arg)
\n
\nThanks for your work.
\n
\n/Mats
\n
\nIf Emacs crashed, and you have the Emacs process in the gdb debugger,
\nplease include the output from the following gdb commands:
\n    `bt full' and `xbacktrace'.
\nIf you would like to further debug the crash, please read the file
\nc:/ProgramFiles/emacs-22.2/etc/DEBUG for instructions.
\n
\n
\nIn GNU Emacs 22.2.1 (i386-mingw-nt5.0.2195)
\n of 2008-03-26 on RELEASE
\nWindowing system distributor `Microsoft Corp.', version 5.0.2195
\nconfigured using `configure --with-gcc (3.4)'
\n
\nImportant settings:
\n  value of $LC_ALL: nil
\n  value of $LC_COLLATE: nil
\n  value of $LC_CTYPE: nil
\n  value of $LC_MESSAGES: nil
\n  value of $LC_MONETARY: nil
\n  value of $LC_NUMERIC: nil
\n  value of $LC_TIME: nil
\n  value of $LANG: SVE
\n  locale-coding-system: cp1252
\n  default-enable-multibyte-characters: t
\n
\nMajor mode: Emacs-Lisp
\n
\nMinor modes in effect:
\n  encoded-kbd-mode: t
\n  tooltip-mode: t
\n  tool-bar-mode: t
\n  mouse-wheel-mode: t
\n  menu-bar-mode: t
\n  file-name-shadow-mode: t
\n  global-font-lock-mode: t
\n  font-lock-mode: t
\n  blink-cursor-mode: t
\n  unify-8859-on-encoding-mode: t
\n  utf-translate-cjk-mode: t
\n  auto-compression-mode: t
\n  line-number-mode: t
\n
\nRecent input:
\nC-x C-f C-a C-k c : / t e m p / f w f . e l <return>
\nM-> C-x C-e M-< M-x f i n d w <tab> <return> M-x e m
\n<backspace> <backspace> r e p o r t SPC e m a <tab>
\n<return>
\n
\nRecent messages:
\nLoading encoded-kb...done
\nFor information about GNU Emacs and the GNU system, type C-h C-a.
\nfwf.el has auto save data; consider M-x recover-this-file
\nMark set
\n(lambda (&optional arg) \"Keyboard macro.\" (interactive \"p\")
\n(kmacro-exec-ring-item (quote (\"=13file\" 0 \"%d\")) arg))
\nMark set
\nfindwordfile: Symbol's function definition is void: kmacro-exec-ring-item
\nLoading emacsbug...
\nLoading regexp-opt...done
\nLoading emacsbug...done
\n
\n
\n
\n
\n------------=_1217977809-519-0
\nContent-Type: message/rfc822
\nContent-Disposition: inline
\nContent-Transfer-Encoding: 7bit
\n
\nX-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02
\n      (2007-08-08) on rzlab.ucr.edu
\nX-Spam-Level: 
\nX-Spam-Status: No, score=-3.2 required=4.0 tests=AWL,BAYES_00 autolearn=ham
\n      version=3.2.3-bugs.debian.org_2005_01_02
\nReceived: (at 331-done) by emacsbugs.donarmstrong.com; 5 Aug 2008 23:00:06 
+0000
\nReceived: from cyd (CYD.MIT.EDU [18.115.2.24])
\n      by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m75N02Ac029108
\n      for <331-done@emacsbugs.donarmstrong.com>; Tue, 5 Aug 2008 16:00:03 
-0700
\nReceived: by cyd (Postfix, from userid 1000)
\n      id 027C957E338; Tue,  5 Aug 2008 19:00:30 -0400 (EDT)
\nFrom: Chong Yidong <cyd@stupidchicken.com>
\nTo: \"Matzi Kratzi\" <matzikratzi@gmail.com>
\nCc: 331-done@emacsbugs.donarmstrong.com
\nSubject: Re: Bug in kmacro.el?
\nDate: Tue, 05 Aug 2008 19:00:29 -0400
\nMessage-ID: <87hc9zxe2a.fsf@stupidchicken.com>
\nMIME-Version: 1.0
\nContent-Type: text/plain; charset=us-ascii
\n
\nThanks.  I've checked in a fix (autoloading kmacro-exec-ring-item, as
\nyou suggested).
\n
\n
\n------------=_1217977809-519-0--
\n
\n)
\n1935 OK UID FETCH completed
\n")
+  ;;   accept-process-output(#<process imap> 0 100 nil)
+  ;;   apply(accept-process-output #<process imap> (0 100))
+  ;;   byte-code("\302\303    #\207" [proc args apply accept-process-output] 
4)
+  ;;   imap-accept-process-output(#<process imap> 0 100)
+  ;;   imap-wait-for-tag(1936 nil)
+  ;;   imap-send-command-wait("EXAMINE \"diro\"")
+  ;;   imap-mailbox-select-1("diro" examine)
+  ;;   imap-mailbox-examine-1("diro")
+  ;;   imap-message-copyuid-1("diro")
+  ;;   imap-message-copy("36250" "diro" dontcreate nil " *nnimap* diro")
+  ;;   nnimap-request-accept-article("diro" "diro" t)
+  ;;   gnus-request-accept-article("nnimap+diro:diro" nil t t)
+  ;;   eval((gnus-request-accept-article "nnimap+diro:diro" (quote nil) t t))
+  ;;   nnimap-request-move-article(36250 "inbox" "diro" 
(gnus-request-accept-article "nnimap+diro:diro" (quote nil) t t) t t)
+  ;;   gnus-request-move-article(36250 "nnimap+diro:inbox" "diro" 
(gnus-request-accept-article "nnimap+diro:diro" (quote nil) t t) t t)
+  ;;   gnus-summary-move-article(nil)
+  ;;   call-interactively(gnus-summary-move-article nil nil)
+  (condition-case nil
+      (apply 'accept-process-output proc args)
+    (quit
+     ;; The IMAP connection can get stuck (not sure why: it may have
+     ;; to do with NAT routers, changing private network, or changing
+     ;; your IP address).
+     ;; Something somewhere should catch this and timeout
+     ;; after a little while, but it seems like currently it doesn't
+     ;; happen, so instead let the user hit C-g to cause the
+     ;; connection to be dropped, so it can be re-opened from scratch.
+     (delete-process proc)
+     (signal 'quit nil))))
+
 (defun imap-wait-for-tag (tag &optional buffer)
   (with-current-buffer (or buffer (current-buffer))
     (let (imap-have-messaged)
@@ -2040,7 +2096,8 @@
          (unless (< len 10)
            (setq imap-have-messaged t)
            (message "imap read: %dk" len))
-         (accept-process-output imap-process
+         (imap-accept-process-output
+           imap-process
                                 (truncate imap-read-timeout)
                                 (truncate (* (- imap-read-timeout
                                                 (truncate imap-read-timeout))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]