Don't infloop if the IMAP connection drops.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sun, 19 Sep 2010 13:00:10 +0000 (15:00 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sun, 19 Sep 2010 13:00:10 +0000 (15:00 +0200)
lisp/ChangeLog
lisp/nnimap.el

index b167a2f..09edbdd 100644 (file)
@@ -4,6 +4,8 @@
        (nnimap-open-connection): Allow anonymous login.
        (nnimap-transform-headers): The chars header is called Chars not
        Bytes.
+       (nnimap-wait-for-response): Don't infloop if the IMAP connection
+       drops.
 
        * gnus-art.el (gnus-article-describe-briefly): Fix up typo in last
        patch, found by Knut Anders Hatlen.
index 630540c..2675df3 100644 (file)
@@ -839,14 +839,17 @@ Possible choices are nil (use default methods) or `anonymous'.")
         (match-string 0))))
 
 (defun nnimap-wait-for-response (sequence &optional messagep)
-  (goto-char (point-max))
-  (while (not (re-search-backward (format "^%d .*\n" sequence)
-                                 (max (point-min) (- (point) 500))
-                                 t))
-    (when messagep
-      (message "Read %dKB" (/ (buffer-size) 1000)))
-    (nnheader-accept-process-output (get-buffer-process (current-buffer)))
-    (goto-char (point-max))))
+  (let ((process (get-buffer-process (current-buffer))))
+    (goto-char (point-max))
+    (while (and (memq (process-status process)
+                     '(open run))
+               (not (re-search-backward (format "^%d .*\n" sequence)
+                                        (max (point-min) (- (point) 500))
+                                        t)))
+      (when messagep
+       (message "Read %dKB" (/ (buffer-size) 1000)))
+      (nnheader-accept-process-output process)
+      (goto-char (point-max)))))
 
 (defun nnimap-parse-response ()
   (let ((lines (split-string (nnimap-last-response-string) "\r\n" t))