[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[VM] Why is vm closing imap session on each vm-get-new-mail?
From: |
Mark Diekhans |
Subject: |
[VM] Why is vm closing imap session on each vm-get-new-mail? |
Date: |
Sun, 13 Aug 2017 17:54:32 -0400 |
Does anyone know why vm-imap closes sessions after retrieving
mail? The "The IMAP session protocol" section in vm-imap.e
describes this but doesn't indicate the motivation. There is
also some discusion in the "The IMAP sessions work as follows"
indicates this is because another connection may have deleted
messages.
For some reason, gmail IMAP login has gotten very slow recently;
to the point that I was thinking of running a caching imap proxy
on my laptop :-(
I have changed calls to vm-establish-new-folder-imap-session to
vm-re-establish-folder-imap-session and all seems to work fine
and it's much faster.
However, when I delete a message from the gmail interface and
then do a (vm-imap-synchronize nil) with the connection is open.
I get the below error.
Any insight on the design?
Thanks
Mark
Debugger entered--Lisp error: (void-variable \223594)
symbol-value(\223594)
(cons uid (symbol-value sym))
(cons (cons uid (symbol-value sym)) retrieve-list)
(setq retrieve-list (cons (cons uid (symbol-value sym)) retrieve-list))
(if (or do-full-retrieve (null retrieved-entry)) (setq retrieve-list (cons
(cons uid (symbol-value sym)) retrieve-list)) (setq remote-expunge-list (cons
(cons uid uid-validity) remote-expunge-list)))
(if (boundp (intern uid here)) nil (setq retrieved-entry (vm-find
vm-imap-retrieved-messages (function (lambda (entry) (and (equal (car entry)
uid) (equal (car ...) uid-validity)))))) (if (or do-full-retrieve (null
retrieved-entry)) (setq retrieve-list (cons (cons uid (symbol-value sym))
retrieve-list)) (setq remote-expunge-list (cons (cons uid uid-validity)
remote-expunge-list))))
(let ((uid (symbol-name sym))) (if (boundp (intern uid here)) nil (setq
retrieved-entry (vm-find vm-imap-retrieved-messages (function (lambda (entry)
(and (equal ... uid) (equal ... uid-validity)))))) (if (or do-full-retrieve
(null retrieved-entry)) (setq retrieve-list (cons (cons uid (symbol-value sym))
retrieve-list)) (setq remote-expunge-list (cons (cons uid uid-validity)
remote-expunge-list)))))
(lambda (sym) (let ((uid (symbol-name sym))) (if (boundp (intern uid here))
nil (setq retrieved-entry (vm-find vm-imap-retrieved-messages (function (lambda
(entry) (and ... ...))))) (if (or do-full-retrieve (null retrieved-entry))
(setq retrieve-list (cons (cons uid (symbol-value sym)) retrieve-list)) (setq
remote-expunge-list (cons (cons uid uid-validity)
remote-expunge-list))))))(\223594)
mapatoms((lambda (sym) (let ((uid (symbol-name sym))) (if (boundp (intern uid
here)) nil (setq retrieved-entry (vm-find vm-imap-retrieved-messages (function
(lambda (entry) (and ... ...))))) (if (or do-full-retrieve (null
retrieved-entry)) (setq retrieve-list (cons (cons uid (symbol-value sym))
retrieve-list)) (setq remote-expunge-list (cons (cons uid uid-validity)
remote-expunge-list)))))) [\223634 \223635 \223636 \223637 \223701 \223745
\223703 \223704 \223705 \223706 \223707 \223708 \223640 \223641 \223642 \223600
\223601 \223602 \223603 \223604 \223605 \223649 \223607 \223608 \223609 \223584
\223585 \223586 \223650 \223588 \223695 \223610 \223611 \223612 \223613 \223614
\223615 \223590 \223591 \223618 \223619 \223594 \223727 \223596 \223597 \223598
\223599 \223620 \223621 \223622 ...])
(let ((here (make-vector 67 0)) there flags (uid-validity
(vm-folder-imap-uid-validity)) (do-full-retrieve (eq do-retrieves (quote
full))) retrieve-list remote-expunge-list local-expunge-list stale-list uid mp
retrieved-entry) (vm-imap-retrieve-uid-and-flags-data) (setq there
(vm-folder-imap-uid-obarray)) (setq mp vm-message-list) (while mp (cond ((not
(equal (vm-imap-uid-validity-of (car mp)) uid-validity)) (setq stale-list (cons
(car mp) stale-list))) ((member "stale" (vm-decoded-labels-of (car mp))) nil)
(t (setq uid (vm-imap-uid-of (car mp))) (set (intern uid here) (car mp)) (if
(not (boundp (intern uid there))) (setq local-expunge-list (cons (car mp)
local-expunge-list))))) (setq mp (cdr mp))) (mapatoms (function (lambda (sym)
(let ((uid (symbol-name sym))) (if (boundp (intern uid here)) nil (setq
retrieved-entry (vm-find vm-imap-retrieved-messages ...)) (if (or
do-full-retrieve ...) (setq retrieve-list ...) (setq remote-expunge-list
...)))))) there) (setq retrieve-list (sort retrieve-list (function (lambda
(**pair1 **pair2) (< (cdr **pair1) (cdr **pair2)))))) (list retrieve-list
remote-expunge-list local-expunge-list stale-list))
vm-imap-get-synchronization-data(t)
(let* ((folder-buffer (current-buffer)) (folder-name (buffer-name
folder-buffer)) (process (vm-folder-imap-process)) (imap-buffer (process-buffer
process)) (uid-validity (vm-folder-imap-uid-validity)) (imapdrop
(vm-folder-imap-maildrop-spec)) (folder (or (vm-imap-folder-for-spec imapdrop)
(vm-safe-imapdrop-string imapdrop))) new-messages (sync-data
(vm-imap-get-synchronization-data do-retrieves)) (retrieve-list (nth 0
sync-data)) (remote-expunge-list (nth 1 sync-data)) (local-expunge-list (nth 2
sync-data)) (stale-list (nth 3 sync-data))) (if save-attributes (progn (let
((mp vm-message-list) (errors 0)) (vm-inform 6 "%s: Updating attributes on the
IMAP server... " folder-name) (while mp (if (or (eq save-attributes ...)
(vm-attribute-modflag-of ...)) (condition-case nil (vm-imap-save-message-flags
process ...) (vm-imap-protocol-error ... ...))) (setq mp (cdr mp))) (if (>
errors 0) (vm-inform 3 "%s: Updating attributes on the IMAP server... %d
errors" folder-name errors) (vm-inform 6 "%s: Updating attributes on the IMAP
server... done" folder-name))))) (if retrieve-attributes (progn (let ((mp
vm-message-list) (len (length vm-message-list)) (n 0) uid m mflags) (vm-inform
6 "%s: Retrieving message attributes and labels... " folder-name) (while mp
(setq m (car mp)) (setq uid (vm-imap-uid-of m)) (if (and (equal ...
uid-validity) (vm-folder-imap-uid-msn uid)) (progn (setq mflags ...)
(vm-imap-update-message-flags m mflags t))) (setq mp (cdr mp) n (1+ n)))
(vm-inform 6 "%s: Retrieving message atrributes and labels... done"
folder-name)))) (if (and do-retrieves retrieve-list) (progn (setq new-messages
(vm-imap-retrieve-messages retrieve-list)))) (if do-local-expunges (progn
(vm-inform 6 "%s: Expunging messages in cache... " folder-name)
(vm-expunge-folder :quiet t :just-these-messages local-expunge-list) (if (and
(eq interactive t) stale-list) (if (y-or-n-p (format "%s: Found %s messages
with invalid UIDs. Expunge them? " folder-name (length stale-list)))
(vm-expunge-folder :quiet t :just-these-messages stale-list) (vm-inform 1 "%s:
They will be labelled 'stale'" folder-name) (mapc (function (lambda ... ...))
stale-list))) (vm-inform 6 "%s: Expunging messages in cache... done"
folder-name))) (if (and do-remote-expunges (if (eq do-remote-expunges (quote
all)) (setq vm-imap-messages-to-expunge remote-expunge-list)
vm-imap-messages-to-expunge)) (progn (vm-imap-expunge-remote-messages))) (setq
vm-imap-connection-mode (quote online)) new-messages)
(if (or vm-global-block-new-mail (eq vm-imap-connection-mode (quote offline))
(null (vm-re-establish-folder-imap-session interactive "general operation"
nil))) (vm-imap-server-error "Could not connect to the IMAP server") (if
do-retrieves (vm-assimilate-new-messages)) (vm-inform 6 "%s: Logging into the
IMAP server..." (buffer-name)) (let* ((folder-buffer (current-buffer))
(folder-name (buffer-name folder-buffer)) (process (vm-folder-imap-process))
(imap-buffer (process-buffer process)) (uid-validity
(vm-folder-imap-uid-validity)) (imapdrop (vm-folder-imap-maildrop-spec))
(folder (or (vm-imap-folder-for-spec imapdrop) (vm-safe-imapdrop-string
imapdrop))) new-messages (sync-data (vm-imap-get-synchronization-data
do-retrieves)) (retrieve-list (nth 0 sync-data)) (remote-expunge-list (nth 1
sync-data)) (local-expunge-list (nth 2 sync-data)) (stale-list (nth 3
sync-data))) (if save-attributes (progn (let ((mp vm-message-list) (errors 0))
(vm-inform 6 "%s: Updating attributes on the IMAP server... " folder-name)
(while mp (if (or ... ...) (condition-case nil ... ...)) (setq mp (cdr mp)))
(if (> errors 0) (vm-inform 3 "%s: Updating attributes on the IMAP server... %d
errors" folder-name errors) (vm-inform 6 "%s: Updating attributes on the IMAP
server... done" folder-name))))) (if retrieve-attributes (progn (let ((mp
vm-message-list) (len (length vm-message-list)) (n 0) uid m mflags) (vm-inform
6 "%s: Retrieving message attributes and labels... " folder-name) (while mp
(setq m (car mp)) (setq uid (vm-imap-uid-of m)) (if (and ... ...) (progn ...
...)) (setq mp (cdr mp) n (1+ n))) (vm-inform 6 "%s: Retrieving message
atrributes and labels... done" folder-name)))) (if (and do-retrieves
retrieve-list) (progn (setq new-messages (vm-imap-retrieve-messages
retrieve-list)))) (if do-local-expunges (progn (vm-inform 6 "%s: Expunging
messages in cache... " folder-name) (vm-expunge-folder :quiet t
:just-these-messages local-expunge-list) (if (and (eq interactive t)
stale-list) (if (y-or-n-p (format "%s: Found %s messages with invalid UIDs.
Expunge them? " folder-name ...)) (vm-expunge-folder :quiet t
:just-these-messages stale-list) (vm-inform 1 "%s: They will be labelled
'stale'" folder-name) (mapc (function ...) stale-list))) (vm-inform 6 "%s:
Expunging messages in cache... done" folder-name))) (if (and do-remote-expunges
(if (eq do-remote-expunges (quote all)) (setq vm-imap-messages-to-expunge
remote-expunge-list) vm-imap-messages-to-expunge)) (progn
(vm-imap-expunge-remote-messages))) (setq vm-imap-connection-mode (quote
online)) new-messages))
(progn (if vm-buffer-type-debug (setq vm-buffer-type-trail (cons (quote
synchronize) vm-buffer-type-trail))) (vm-buffer-type:set (quote folder))
(vm-imap-init-log) (vm-imap-log-tokens (list (quote synchronize)
(current-buffer) (vm-folder-imap-process))) (setq vm-buffer-type-trail nil) (if
(and do-retrieves vm-block-new-mail) (error "Can't get new mail until you save
this folder")) (if (or vm-global-block-new-mail (eq vm-imap-connection-mode
(quote offline)) (null (vm-re-establish-folder-imap-session interactive
"general operation" nil))) (vm-imap-server-error "Could not connect to the IMAP
server") (if do-retrieves (vm-assimilate-new-messages)) (vm-inform 6 "%s:
Logging into the IMAP server..." (buffer-name)) (let* ((folder-buffer
(current-buffer)) (folder-name (buffer-name folder-buffer)) (process
(vm-folder-imap-process)) (imap-buffer (process-buffer process)) (uid-validity
(vm-folder-imap-uid-validity)) (imapdrop (vm-folder-imap-maildrop-spec))
(folder (or (vm-imap-folder-for-spec imapdrop) (vm-safe-imapdrop-string
imapdrop))) new-messages (sync-data (vm-imap-get-synchronization-data
do-retrieves)) (retrieve-list (nth 0 sync-data)) (remote-expunge-list (nth 1
sync-data)) (local-expunge-list (nth 2 sync-data)) (stale-list (nth 3
sync-data))) (if save-attributes (progn (let ((mp vm-message-list) (errors 0))
(vm-inform 6 "%s: Updating attributes on the IMAP server... " folder-name)
(while mp (if ... ...) (setq mp ...)) (if (> errors 0) (vm-inform 3 "%s:
Updating attributes on the IMAP server... %d errors" folder-name errors)
(vm-inform 6 "%s: Updating attributes on the IMAP server... done"
folder-name))))) (if retrieve-attributes (progn (let ((mp vm-message-list) (len
...) (n 0) uid m mflags) (vm-inform 6 "%s: Retrieving message attributes and
labels... " folder-name) (while mp (setq m ...) (setq uid ...) (if ... ...)
(setq mp ... n ...)) (vm-inform 6 "%s: Retrieving message atrributes and
labels... done" folder-name)))) (if (and do-retrieves retrieve-list) (progn
(setq new-messages (vm-imap-retrieve-messages retrieve-list)))) (if
do-local-expunges (progn (vm-inform 6 "%s: Expunging messages in cache... "
folder-name) (vm-expunge-folder :quiet t :just-these-messages
local-expunge-list) (if (and (eq interactive t) stale-list) (if (y-or-n-p ...)
(vm-expunge-folder :quiet t :just-these-messages stale-list) (vm-inform 1 "%s:
They will be labelled 'stale'" folder-name) (mapc ... stale-list))) (vm-inform
6 "%s: Expunging messages in cache... done" folder-name))) (if (and
do-remote-expunges (if (eq do-remote-expunges (quote all)) (setq
vm-imap-messages-to-expunge remote-expunge-list) vm-imap-messages-to-expunge))
(progn (vm-imap-expunge-remote-messages))) (setq vm-imap-connection-mode (quote
online)) new-messages)))
(progn (let ((--cl-keys-- --cl-rest--)) (while --cl-keys-- (cond ((memq (car
--cl-keys--) (quote (:interactive :do-remote-expunges :do-local-expunges
:do-retrieves :save-attributes :retrieve-attributes :allow-other-keys))) (setq
--cl-keys-- (cdr (cdr --cl-keys--)))) ((car (cdr (memq ... --cl-rest--))) (setq
--cl-keys-- nil)) (t (error "Keyword argument %s not one of (:interactive
:do-remote-expunges :do-local-expunges :do-retrieves :save-attributes
:retrieve-attributes)" (car --cl-keys--)))))) (progn (if vm-buffer-type-debug
(setq vm-buffer-type-trail (cons (quote synchronize) vm-buffer-type-trail)))
(vm-buffer-type:set (quote folder)) (vm-imap-init-log) (vm-imap-log-tokens
(list (quote synchronize) (current-buffer) (vm-folder-imap-process))) (setq
vm-buffer-type-trail nil) (if (and do-retrieves vm-block-new-mail) (error
"Can't get new mail until you save this folder")) (if (or
vm-global-block-new-mail (eq vm-imap-connection-mode (quote offline)) (null
(vm-re-establish-folder-imap-session interactive "general operation" nil)))
(vm-imap-server-error "Could not connect to the IMAP server") (if do-retrieves
(vm-assimilate-new-messages)) (vm-inform 6 "%s: Logging into the IMAP
server..." (buffer-name)) (let* ((folder-buffer (current-buffer)) (folder-name
(buffer-name folder-buffer)) (process (vm-folder-imap-process)) (imap-buffer
(process-buffer process)) (uid-validity (vm-folder-imap-uid-validity))
(imapdrop (vm-folder-imap-maildrop-spec)) (folder (or (vm-imap-folder-for-spec
imapdrop) (vm-safe-imapdrop-string imapdrop))) new-messages (sync-data
(vm-imap-get-synchronization-data do-retrieves)) (retrieve-list (nth 0
sync-data)) (remote-expunge-list (nth 1 sync-data)) (local-expunge-list (nth 2
sync-data)) (stale-list (nth 3 sync-data))) (if save-attributes (progn (let
(... ...) (vm-inform 6 "%s: Updating attributes on the IMAP server... "
folder-name) (while mp ... ...) (if ... ... ...)))) (if retrieve-attributes
(progn (let (... ... ... uid m mflags) (vm-inform 6 "%s: Retrieving message
attributes and labels... " folder-name) (while mp ... ... ... ...) (vm-inform 6
"%s: Retrieving message atrributes and labels... done" folder-name)))) (if (and
do-retrieves retrieve-list) (progn (setq new-messages
(vm-imap-retrieve-messages retrieve-list)))) (if do-local-expunges (progn
(vm-inform 6 "%s: Expunging messages in cache... " folder-name)
(vm-expunge-folder :quiet t :just-these-messages local-expunge-list) (if (and
... stale-list) (if ... ... ... ...)) (vm-inform 6 "%s: Expunging messages in
cache... done" folder-name))) (if (and do-remote-expunges (if (eq
do-remote-expunges ...) (setq vm-imap-messages-to-expunge remote-expunge-list)
vm-imap-messages-to-expunge)) (progn (vm-imap-expunge-remote-messages))) (setq
vm-imap-connection-mode (quote online)) new-messages))))
(let* ((interactive (car (cdr (plist-member --cl-rest-- (quote
:interactive))))) (do-remote-expunges (car (cdr (plist-member --cl-rest--
(quote :do-remote-expunges))))) (do-local-expunges (car (cdr (plist-member
--cl-rest-- (quote :do-local-expunges))))) (do-retrieves (car (cdr
(plist-member --cl-rest-- (quote :do-retrieves))))) (save-attributes (car (cdr
(plist-member --cl-rest-- (quote :save-attributes))))) (retrieve-attributes
(car (cdr (plist-member --cl-rest-- (quote :retrieve-attributes)))))) (progn
(let ((--cl-keys-- --cl-rest--)) (while --cl-keys-- (cond ((memq (car
--cl-keys--) (quote ...)) (setq --cl-keys-- (cdr ...))) ((car (cdr ...)) (setq
--cl-keys-- nil)) (t (error "Keyword argument %s not one of (:interactive
:do-remote-expunges :do-local-expunges :do-retrieves :save-attributes
:retrieve-attributes)" (car --cl-keys--)))))) (progn (if vm-buffer-type-debug
(setq vm-buffer-type-trail (cons (quote synchronize) vm-buffer-type-trail)))
(vm-buffer-type:set (quote folder)) (vm-imap-init-log) (vm-imap-log-tokens
(list (quote synchronize) (current-buffer) (vm-folder-imap-process))) (setq
vm-buffer-type-trail nil) (if (and do-retrieves vm-block-new-mail) (error
"Can't get new mail until you save this folder")) (if (or
vm-global-block-new-mail (eq vm-imap-connection-mode (quote offline)) (null
(vm-re-establish-folder-imap-session interactive "general operation" nil)))
(vm-imap-server-error "Could not connect to the IMAP server") (if do-retrieves
(vm-assimilate-new-messages)) (vm-inform 6 "%s: Logging into the IMAP
server..." (buffer-name)) (let* ((folder-buffer (current-buffer)) (folder-name
(buffer-name folder-buffer)) (process (vm-folder-imap-process)) (imap-buffer
(process-buffer process)) (uid-validity (vm-folder-imap-uid-validity))
(imapdrop (vm-folder-imap-maildrop-spec)) (folder (or ... ...)) new-messages
(sync-data (vm-imap-get-synchronization-data do-retrieves)) (retrieve-list (nth
0 sync-data)) (remote-expunge-list (nth 1 sync-data)) (local-expunge-list (nth
2 sync-data)) (stale-list (nth 3 sync-data))) (if save-attributes (progn (let
... ... ... ...))) (if retrieve-attributes (progn (let ... ... ... ...))) (if
(and do-retrieves retrieve-list) (progn (setq new-messages ...))) (if
do-local-expunges (progn (vm-inform 6 "%s: Expunging messages in cache... "
folder-name) (vm-expunge-folder :quiet t :just-these-messages
local-expunge-list) (if ... ...) (vm-inform 6 "%s: Expunging messages in
cache... done" folder-name))) (if (and do-remote-expunges (if ... ...
vm-imap-messages-to-expunge)) (progn (vm-imap-expunge-remote-messages))) (setq
vm-imap-connection-mode (quote online)) new-messages)))))
vm-imap-synchronize-folder(:interactive t :do-local-expunges t :do-retrieves
t :save-attributes t :retrieve-attributes t)
vm-get-spooled-mail(t)
vm-get-new-mail(nil)
funcall-interactively(vm-get-new-mail nil)
call-interactively(vm-get-new-mail nil nil)
command-execute(vm-get-new-mail)
- [VM] Why is vm closing imap session on each vm-get-new-mail?,
Mark Diekhans <=