aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-07-03 12:57:29 +0200
committerLars Ingebrigtsen2022-07-03 12:57:29 +0200
commit5a094d16e358de13d6a8caa26ec91fea85125cf8 (patch)
tree470dc8650592208800df9ed3b471ce2702254ff0
parentb31680ef040d4a232619e8d070794a43d2cdca2c (diff)
downloademacs-5a094d16e358de13d6a8caa26ec91fea85125cf8.tar.gz
emacs-5a094d16e358de13d6a8caa26ec91fea85125cf8.zip
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.el30
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."
241 (when (nnimap-change-group group server) 241 (when (nnimap-change-group group server)
242 (with-current-buffer (nnimap-buffer) 242 (with-current-buffer (nnimap-buffer)
243 (erase-buffer) 243 (erase-buffer)
244 (let ((ranges (gnus-compress-sequence articles t)) 244 ;; If we have a lot of ranges, split them up to avoid
245 sequence) 245 ;; generating too-long lines. (The limit is 8192 octects,
246 ;; If we have a lot of ranges, split them up to avoid 246 ;; and this should guarantee that it's (much) shorter than
247 ;; generating too-long lines. (The limit is 8192 octects, 247 ;; that.) We don't stream the requests, since the server
248 ;; and this should guarantee that it's (much) shorter than 248 ;; may respond to the requests out-of-order:
249 ;; that.) 249 ;; https://datatracker.ietf.org/doc/html/rfc3501#section-5.5
250 (while ranges 250 (dolist (ranges (seq-split (gnus-compress-sequence articles t)
251 (setq sequence 251 nnimap--max-retrieve-headers))
252 (nnimap-send-command 252 (nnimap-wait-for-response
253 "UID FETCH %s %s" 253 (nnimap-send-command
254 (nnimap-article-ranges 254 "UID FETCH %s %s"
255 (seq-take ranges nnimap--max-retrieve-headers)) 255 (nnimap-article-ranges ranges)
256 (nnimap-header-parameters))) 256 (nnimap-header-parameters))
257 (setq ranges (nthcdr nnimap--max-retrieve-headers ranges))) 257 t))
258 ;; Wait for the final one.
259 (nnimap-wait-for-response sequence t))
260 (unless (process-live-p (get-buffer-process (current-buffer))) 258 (unless (process-live-p (get-buffer-process (current-buffer)))
261 (error "IMAP server %S closed connection" nnimap-address)) 259 (error "IMAP server %S closed connection" nnimap-address))
262 (nnimap-transform-headers) 260 (nnimap-transform-headers)