From 75a96213bfcfcf1d3b808d020b94c7049c0b5f2c Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Sun, 19 Sep 2010 15:00:10 +0200 Subject: [PATCH] Don't infloop if the IMAP connection drops. --- lisp/ChangeLog | 2 ++ lisp/nnimap.el | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b167a2f2d..09edbdd8a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -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. diff --git a/lisp/nnimap.el b/lisp/nnimap.el index 630540c0a..2675df3c9 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -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)) -- 2.25.1