summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorEric Abrahamsen <eric@ericabrahamsen.net>2021-10-11 08:45:09 -0700
committerEric Abrahamsen <eric@ericabrahamsen.net>2021-10-12 13:00:05 -0700
commite47b85a68339063dd3a784e8b90aecbf90b23f41 (patch)
tree59133ec2fc2097453409194b219955aeb2b40f11 /lisp
parent85edcf7af5d897fcc94ef1a0efb527c4b5e2bcc5 (diff)
downloademacs-e47b85a68339063dd3a784e8b90aecbf90b23f41.tar.gz
emacs-e47b85a68339063dd3a784e8b90aecbf90b23f41.tar.bz2
emacs-e47b85a68339063dd3a784e8b90aecbf90b23f41.zip
Clean up nnimap buffers with dead processes
* lisp/gnus/nnimap.el (nnimap-keepalive): If the keepalive "NOOP" fails, remove the buffer with the dead process from `nnimap-process-buffers' and `nnimap-connection-alist'. (nnimap-find-connection): Do the same here, when the connection can't be found. (nnimap-close-server): Remove process buffer from lists when closing server.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/gnus/nnimap.el38
1 files changed, 29 insertions, 9 deletions
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index 059101c8907..8a2acf6459a 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -429,8 +429,18 @@ during splitting, which may be slow."
now
(nnimap-last-command-time nnimap-object))))
(with-local-quit
- (ignore-errors ;E.g. "buffer foo has no process".
- (nnimap-send-command "NOOP")))))))))
+ (ignore-errors ;E.g. "buffer foo has no process".
+ (nnimap-send-command "NOOP"))
+ ;; If our connection has died in the meantime, clean it
+ ;; and its buffer up.
+ (unless (process-live-p (get-buffer-process buffer))
+ (setq nnimap-process-buffers
+ (delq buffer nnimap-process-buffers))
+ (setq nnimap-connection-alist
+ (seq-filter (lambda (elt)
+ (null (eq buffer (cdr elt))))
+ nnimap-connection-alist))
+ (kill-buffer buffer)))))))))
(defun nnimap-open-connection (buffer)
;; Be backwards-compatible -- the earlier value of nnimap-stream was
@@ -662,10 +672,17 @@ during splitting, which may be slow."
(deffoo nnimap-close-server (&optional server defs)
(when (nnoo-change-server 'nnimap server defs)
- (ignore-errors
- (delete-process (get-buffer-process (nnimap-buffer))))
- (nnoo-close-server 'nnimap server)
- t))
+ (let ((buf (nnimap-buffer)))
+ (ignore-errors
+ (delete-process (get-buffer-process buf)))
+ (setq nnimap-process-buffers
+ (delq buf nnimap-process-buffers)
+ nnimap-connection-alist
+ (seq-filter (lambda (elt)
+ (null (eq buf (cdr elt))))
+ nnimap-connection-alist))
+ (nnoo-close-server 'nnimap server)
+ t)))
(deffoo nnimap-request-close ()
t)
@@ -1937,10 +1954,13 @@ Return the server's response to the SELECT or EXAMINE command."
(when entry
(if (and (buffer-live-p (cadr entry))
(get-buffer-process (cadr entry))
- (memq (process-status (get-buffer-process (cadr entry)))
- '(open run)))
+ (process-live-p (get-buffer-process (cadr entry))))
(get-buffer-process (cadr entry))
- (setq nnimap-connection-alist (delq entry nnimap-connection-alist))
+ (setq nnimap-connection-alist (delq entry nnimap-connection-alist)
+ nnimap-process-buffers
+ (delq (cadr entry) nnimap-process-buffers))
+ (when (buffer-live-p (cadr entry))
+ (kill-buffer (cadr entry)))
nil))))
;; Leave room for `open-network-stream' to issue a couple of IMAP