From: Lars Ingebrigtsen Date: Sun, 3 Jul 2022 10:57:29 +0000 (+0200) Subject: Fix streaming problems in nnimap-retrieve-headers X-Git-Tag: emacs-29.0.90~1447^2~1243 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5a094d16e358de13d6a8caa26ec91fea85125cf8;p=emacs.git Fix streaming problems in nnimap-retrieve-headers * lisp/gnus/nnimap.el (nnimap-retrieve-headers): Don't stream the UID FETCH commands, since the server may return the results out-of-order (bug#56332). --- diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index 22edc3c72cf..c629cb85d96 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el @@ -241,22 +241,20 @@ during splitting, which may be slow." (when (nnimap-change-group group server) (with-current-buffer (nnimap-buffer) (erase-buffer) - (let ((ranges (gnus-compress-sequence articles t)) - sequence) - ;; If we have a lot of ranges, split them up to avoid - ;; generating too-long lines. (The limit is 8192 octects, - ;; and this should guarantee that it's (much) shorter than - ;; that.) - (while ranges - (setq sequence - (nnimap-send-command - "UID FETCH %s %s" - (nnimap-article-ranges - (seq-take ranges nnimap--max-retrieve-headers)) - (nnimap-header-parameters))) - (setq ranges (nthcdr nnimap--max-retrieve-headers ranges))) - ;; Wait for the final one. - (nnimap-wait-for-response sequence t)) + ;; If we have a lot of ranges, split them up to avoid + ;; generating too-long lines. (The limit is 8192 octects, + ;; and this should guarantee that it's (much) shorter than + ;; that.) We don't stream the requests, since the server + ;; may respond to the requests out-of-order: + ;; https://datatracker.ietf.org/doc/html/rfc3501#section-5.5 + (dolist (ranges (seq-split (gnus-compress-sequence articles t) + nnimap--max-retrieve-headers)) + (nnimap-wait-for-response + (nnimap-send-command + "UID FETCH %s %s" + (nnimap-article-ranges ranges) + (nnimap-header-parameters)) + t)) (unless (process-live-p (get-buffer-process (current-buffer))) (error "IMAP server %S closed connection" nnimap-address)) (nnimap-transform-headers)