diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2022-07-03 12:57:29 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-07-03 12:57:29 +0200 |
commit | 5a094d16e358de13d6a8caa26ec91fea85125cf8 (patch) | |
tree | 470dc8650592208800df9ed3b471ce2702254ff0 | |
parent | b31680ef040d4a232619e8d070794a43d2cdca2c (diff) | |
download | emacs-5a094d16e358de13d6a8caa26ec91fea85125cf8.tar.gz |
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).
-rw-r--r-- | lisp/gnus/nnimap.el | 30 |
1 files changed, 14 insertions, 16 deletions
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) |