From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#43682: 28.0.50; Clean up nnimap server buffers? Date: Wed, 30 Sep 2020 22:09:11 -0700 Message-ID: <871rii7cso.fsf@ericabrahamsen.net> References: <87eemlh3ro.fsf@ericabrahamsen.net> <87d024bpqc.fsf@gnus.org> <87mu18qw3g.fsf@ericabrahamsen.net> <87k0wc9i4k.fsf@gnus.org> <87tuvfc4ur.fsf@ericabrahamsen.net> <87d022wx5y.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39476"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 43682@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 01 07:10:15 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNqr9-000A8m-3E for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Oct 2020 07:10:15 +0200 Original-Received: from localhost ([::1]:60660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNqr8-0002Xw-3n for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Oct 2020 01:10:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNqqw-0002Wx-CQ for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 01:10:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50505) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kNqqw-0004aP-25 for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 01:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kNqqv-0000sO-TV for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 01:10:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Oct 2020 05:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43682 X-GNU-PR-Package: emacs Original-Received: via spool by 43682-submit@debbugs.gnu.org id=B43682.16015289613308 (code B ref 43682); Thu, 01 Oct 2020 05:10:01 +0000 Original-Received: (at 43682) by debbugs.gnu.org; 1 Oct 2020 05:09:21 +0000 Original-Received: from localhost ([127.0.0.1]:33818 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNqqH-0000rI-JY for submit@debbugs.gnu.org; Thu, 01 Oct 2020 01:09:21 -0400 Original-Received: from ericabrahamsen.net ([52.70.2.18]:48176 helo=mail.ericabrahamsen.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNqqF-0000r3-28 for 43682@debbugs.gnu.org; Thu, 01 Oct 2020 01:09:20 -0400 Original-Received: from localhost (c-73-254-86-141.hsd1.wa.comcast.net [73.254.86.141]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id B0F6AFA5B6; Thu, 1 Oct 2020 05:09:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1601528952; bh=yqeGwFm7UjvwJDTlbpJI+bLXYb8vIoxiNW99RPEfrJA=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=T0dCZeVW5ynqEbUZTiV+cF5YmBDrJxKo/Plgm4QEt5kqrac2dk0al4mO4orYpBRD4 mwsx2rhg0+9uQV2U3HMjbQ4v/l9Et0PmzeJzt63S6EUxrwUPHfzNb8L7roGI/mLHJz 4Shz923KBhqfbbboE9pbd44/lX3euvS62Q3f0Ghw= In-Reply-To: <87d022wx5y.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 01 Oct 2020 03:30:01 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:189471 Archived-At: --=-=-= Content-Type: text/plain On 10/01/20 03:30 AM, Lars Ingebrigtsen wrote: > Eric Abrahamsen writes: > >> So that's what it's for! That's a mystery solved. It appears that only >> nntp is asynchronous: at least, it's the only backend that implements >> `gnus-asynchronous-p'. > > Aha. nnimap should, too. > >> nntp.el also contains `nntp-async-{wait,stop-trigger}', but as far as I >> can tell that has nothing to do with gnus-async.el stuff (?). That's the >> code that appears to make use of "extra processes per server", and >> nnimap doesn't have any of that. > > Yes, that's a separate thing... > >> Not so far as I can tell. sieve.el and sieve-mode.el don't have anything >> to do with Gnus, and gnus-sieve.el is just about building sieve scripts >> from Gnus splitting rules. (Now that you mention it, it would be nice if >> there were a command to edit an IMAP server's sieve scripts from the >> *Server* buffer.) > > Right. I think there was once some talk about this stuff, but oy vey > the years... I'll add it to my own todo list, where it can likewise languish for years. >> I'm inclined to delete the alist altogether, but if we keep it at least >> I can give it a docstring. > > No, we should keep it and implement the stuff for gnus-asynchronous-p in > nnimap, too. It's possible (I'm not claiming to understand all the code) that all we would need to do is fix `gnus-async-wait-for-article' to replace its calls to `nntp-find-connection' and `nntp-accept-process-output' with something generalized. Those two functions deal with directly with `nntp-connection-alist', so we'd need something that would do the equivalent with `nnimap-connection-alist'. Anyway, in the interest of completing this far less ambitious patch: if the nnimap connection has timed out, we should remove this connection from `nnimap-connection-alist', so this version of the patch does that. If async has opened a second connection, I guess we should leave that alone, though I don't have too much confidence that the whole process will recover gracefully from the main connection dying... Eric --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=CleanupImapBuffers.diff diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index d797e893f5..bceba574ca 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el @@ -407,8 +407,19 @@ nnimap-keepalive (time-subtract now (nnimap-last-command-time nnimap-object)))) - (ignore-errors ;E.g. "buffer foo has no process". - (nnimap-send-command "NOOP")))))))) + (ignore-errors + (nnimap-send-command "NOOP")) + ;; If our connection has died in the meantime, clean it + ;; and its buffer up. + (unless (memq (process-status (get-buffer-process buffer)) + '(open run)) + (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 @@ -1910,6 +1921,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 --=-=-=--