unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#43682: 28.0.50; Clean up nnimap server buffers?
@ 2020-09-28 23:37 Eric Abrahamsen
  2020-09-29  7:42 ` Robert Pluim
  2020-09-29 14:51 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 15+ messages in thread
From: Eric Abrahamsen @ 2020-09-28 23:37 UTC (permalink / raw)
  To: 43682

[-- Attachment #1: Type: text/plain, Size: 311 bytes --]


Someone noted on gnus.general that their imap connections are frequently
broken, and they end up with a lot of dead process buffers.

I'm talking to them about maybe making the keepalive timeout
configurable, but wouldn't also be tidy to clean up dead process
buffers? How does the attached patch look?

Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: CleanupImapBuffers.diff --]
[-- Type: text/x-patch, Size: 1234 bytes --]

diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index d797e893f5..7f2ebe279e 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -407,8 +407,15 @@ nnimap-keepalive
 		      (time-subtract
 		       now
 		       (nnimap-last-command-time nnimap-object))))
-            (ignore-errors              ;E.g. "buffer foo has no process".
-              (nnimap-send-command "NOOP"))))))))
+	    (condition-case err
+		(process-send-string "NOOP")
+	      (error
+	       (if (string-search "has no process" (cdr err))
+		   (let ((buf (current-buffer)))
+		     (setq nnimap-process-buffers
+			   (delq buf nnimap-process-buffers))
+		     (kill-buffer buf))
+		 (signal (car err) (cdr err)))))))))))
 
 (defun nnimap-open-connection (buffer)
   ;; Be backwards-compatible -- the earlier value of nnimap-stream was
@@ -1910,6 +1917,10 @@ nnimap-find-connection
 		     '(open run)))
 	  (get-buffer-process (cadr entry))
 	(setq nnimap-connection-alist (delq entry nnimap-connection-alist))
+	(setq 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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-10-12 21:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-28 23:37 bug#43682: 28.0.50; Clean up nnimap server buffers? Eric Abrahamsen
2020-09-29  7:42 ` Robert Pluim
2020-09-29 14:51 ` Lars Ingebrigtsen
2020-09-29 18:25   ` Eric Abrahamsen
2020-09-30  1:18     ` Lars Ingebrigtsen
2020-09-30  1:21       ` Lars Ingebrigtsen
2020-09-30 21:49       ` Eric Abrahamsen
2020-10-01  1:30         ` Lars Ingebrigtsen
2020-10-01  5:09           ` Eric Abrahamsen
2020-10-01 16:01             ` Lars Ingebrigtsen
2020-10-01 17:25               ` Eric Abrahamsen
2021-10-11 12:53                 ` Stefan Kangas
2021-10-11 14:41                   ` Eric Abrahamsen
2021-10-12 20:50                   ` Eric Abrahamsen
2021-10-12 21:33                     ` Stefan Kangas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).