[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 5a094d16e3 2/2: Fix streaming problems in nnimap-retrieve-headers
From: |
Lars Ingebrigtsen |
Subject: |
master 5a094d16e3 2/2: Fix streaming problems in nnimap-retrieve-headers |
Date: |
Sun, 3 Jul 2022 07:00:01 -0400 (EDT) |
branch: master
commit 5a094d16e358de13d6a8caa26ec91fea85125cf8
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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).
---
lisp/gnus/nnimap.el | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index 22edc3c72c..c629cb85d9 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)