(nnimap-wait-for-response): If the user hits `C-g', kill the process, too.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sun, 10 Oct 2010 13:24:30 +0000 (15:24 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sun, 10 Oct 2010 13:24:30 +0000 (15:24 +0200)
lisp/ChangeLog
lisp/nnimap.el

index bae698a..1ef90fd 100644 (file)
@@ -1,3 +1,8 @@
+2010-10-10  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * nnimap.el (nnimap-wait-for-response): If the user hits `C-g', kill
+       the process, too.
+
 2010-10-09  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * spam.el (gnus-summary-mode-map): Bind to "$".  Suggested by Russ
index b30e586..6a1c3f5 100644 (file)
@@ -1355,20 +1355,28 @@ textual parts.")
 (defun nnimap-wait-for-response (sequence &optional messagep)
   (let ((process (get-buffer-process (current-buffer)))
        openp)
-    (goto-char (point-max))
-    (while (and (setq openp (memq (process-status process)
-                                 '(open run)))
-               (not (re-search-backward
-                     (format "^%d .*\n" sequence)
-                     (if nnimap-streaming
-                         (max (point-min) (- (point) 500))
-                       (point-min))
-                     t)))
-      (when messagep
-       (message "nnimap read %dk" (/ (buffer-size) 1000)))
-      (nnheader-accept-process-output process)
-      (goto-char (point-max)))
-    openp))
+    (condition-case nil
+        (progn
+         (goto-char (point-max))
+         (while (and (setq openp (memq (process-status process)
+                                       '(open run)))
+                     (not (re-search-backward
+                           (format "^%d .*\n" sequence)
+                           (if nnimap-streaming
+                               (max (point-min) (- (point) 500))
+                             (point-min))
+                           t)))
+           (when messagep
+             (message "nnimap read %dk" (/ (buffer-size) 1000)))
+           (nnheader-accept-process-output process)
+           (goto-char (point-max)))
+          openp)
+      (quit
+       ;; The user hit C-g while we were waiting: kill the process, in case
+       ;; it's a gnutls-cli process that's stuck (tends to happen a lot behind
+       ;; NAT routers).
+       (delete-process process)
+       nil))))
 
 (defun nnimap-parse-response ()
   (let ((lines (split-string (nnimap-last-response-string) "\r\n" t))