GNU bug report logs - #43682
28.0.50; Clean up nnimap server buffers?

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Eric Abrahamsen <eric@HIDDEN>; dated Mon, 28 Sep 2020 23:38:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 43682 <at> debbugs.gnu.org:


Received: (at 43682) by debbugs.gnu.org; 29 Sep 2020 14:51:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 29 10:51:51 2020
Received: from localhost ([127.0.0.1]:56889 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kNGyt-0008C8-DS
	for submit <at> debbugs.gnu.org; Tue, 29 Sep 2020 10:51:51 -0400
Received: from quimby.gnus.org ([95.216.78.240]:34750)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1kNGys-0008Bs-4W
 for 43682 <at> debbugs.gnu.org; Tue, 29 Sep 2020 10:51:50 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=wl0dfgMm9xk0gJwj37uhT0hx/7GPiHiU5lwxo+nhMgw=; b=FdCU55gpK5b+XtXm74wnays4jD
 /RDGcVTP23PkYvy429CffzpOt/dM74ybtOez7awGiQ6K8KcN1lmpcG/EoS7KmR3UNwuzYhnCr8dR8
 4wa4CF6SDJnpNv4WI4vZUNQ96gsLR/FiQnYOyzehhf1yv/2NFjxGW7IMlnfiubBj5jQQ=;
Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo)
 by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1kNGyi-00081o-M8; Tue, 29 Sep 2020 16:51:43 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Eric Abrahamsen <eric@HIDDEN>
Subject: Re: bug#43682: 28.0.50; Clean up nnimap server buffers?
References: <87eemlh3ro.fsf@HIDDEN>
X-Now-Playing: 23 Skidoo's _Seven Songs_: "Tearing Up the Plans Pt. 2"
Date: Tue, 29 Sep 2020 16:51:39 +0200
In-Reply-To: <87eemlh3ro.fsf@HIDDEN> (Eric Abrahamsen's message of
 "Mon, 28 Sep 2020 16:37:15 -0700")
Message-ID: <87d024bpqc.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Eric Abrahamsen <eric@HIDDEN> writes: > -
 (ignore-errors
 ;E.g. "buffer foo has no process". > - (nnimap-send-command "NOOP"))))))))
 > + (condition-case err > + (process-send-string "NOOP") > + (error 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 43682
Cc: 43682 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eric Abrahamsen <eric@HIDDEN> writes:

> -            (ignore-errors              ;E.g. "buffer foo has no process".
> -              (nnimap-send-command "NOOP"))))))))
> +	    (condition-case err
> +		(process-send-string "NOOP")
> +	      (error

As Robert notes, you can't do that; it'll mess up the machiner.

> +	       (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)))))))))))

But why look for a string?  You can just check whether the process is
dead or not.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#43682; Package emacs. Full text available.

Message received at 43682 <at> debbugs.gnu.org:


Received: (at 43682) by debbugs.gnu.org; 29 Sep 2020 07:42:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 29 03:42:14 2020
Received: from localhost ([127.0.0.1]:54858 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kNAH8-0003GV-A3
	for submit <at> debbugs.gnu.org; Tue, 29 Sep 2020 03:42:14 -0400
Received: from mail-wr1-f45.google.com ([209.85.221.45]:40690)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rpluim@HIDDEN>) id 1kNAH7-0003GH-Ce
 for 43682 <at> debbugs.gnu.org; Tue, 29 Sep 2020 03:42:13 -0400
Received: by mail-wr1-f45.google.com with SMTP id j2so4159937wrx.7
 for <43682 <at> debbugs.gnu.org>; Tue, 29 Sep 2020 00:42:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :mime-version:content-transfer-encoding;
 bh=Ch9Xy8g2av8LJp7ST4l8/fa6Va+TTKAaiz1weyYj+cc=;
 b=QAYTw1p0d1CX5wR1pf22HsvowZk/kHf2oG8hOSR7tH69vjf8NC+55tSpTqGW7VbDmw
 csNAHd88bM11c3/wZftlomEAUxGEaaKTVHIBRyrNSUkFwSeufKOEPa8tLHismZRwWNI1
 UVX84gZVljN9tdR9CmKyxK2byLKdsUQujct2QwTRUDda32+wSpzg6rNFtTdsf28hp0z+
 q35rt9o5SbJyOLXMBqMkc5cBAgfk90kur+V55ohqCQ8WPw5MVboT1QeJ/xVO52Jx9WGu
 5O/9sULd7gC+BnEIvJQUNq9it5uolgKf1NM3vTCxMvhGr8okhPEFXlKbII/JONTDWJbT
 mRug==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:mime-version:content-transfer-encoding;
 bh=Ch9Xy8g2av8LJp7ST4l8/fa6Va+TTKAaiz1weyYj+cc=;
 b=nvVlEoQnWPvvjE5vmzLAzsxDHF+t6RBN0M9himKPBomroAsv4wpPYqdAKgLm7g/bCm
 wYrrP3RltD2GXCtcsMbXSrAVnkLyXOB3SU4QbZq0oLdx/WDShw3F78Ugd/8oWDXKLEis
 llPG3dJbW6zDKwYVf2tOgp9yvEt/DwRm5WHqDcJJMtBEsgCNFlFwQf85CDMLU5HjB/Nc
 vTivJ/9MTEdyDXZhnhQjJJaGlyYrMvS1sGurOd6kjM+dr4z2bkyNP1NGqitocvFtVhcu
 H/cKmjThInp3RdNd38/aBxKlchliNhFQ4lMkMnYALHdeubKtTc0xwDiGSkyzBmpCgTzs
 M/Mw==
X-Gm-Message-State: AOAM533/NT9HGZ3yX6AbgY4VMjVBckN0MF7FUJ8Ixx8sxAsEFJSS5z9C
 eKJY0QgO4hFrvbsRxd59XeQ4Q3Ycs18=
X-Google-Smtp-Source: ABdhPJxh0eGViNDzneyxJs2vxM6OjXPCh6dpVDvLxU93QHKuAF2libnEerR86gp3dI55dbtnj+HQ3g==
X-Received: by 2002:adf:92c2:: with SMTP id 60mr2814498wrn.220.1601365326900; 
 Tue, 29 Sep 2020 00:42:06 -0700 (PDT)
Received: from rpluim-mac ([2a01:e34:ecfc:a860:ec55:f484:fbc:8e04])
 by smtp.gmail.com with ESMTPSA id i15sm4857778wrb.91.2020.09.29.00.42.05
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 29 Sep 2020 00:42:05 -0700 (PDT)
From: Robert Pluim <rpluim@HIDDEN>
To: Eric Abrahamsen <eric@HIDDEN>
Subject: Re: bug#43682: 28.0.50; Clean up nnimap server buffers?
References: <87eemlh3ro.fsf@HIDDEN>
Date: Tue, 29 Sep 2020 09:42:05 +0200
In-Reply-To: <87eemlh3ro.fsf@HIDDEN> (Eric Abrahamsen's message of
 "Mon, 28 Sep 2020 16:37:15 -0700")
Message-ID: <m2ft71uj02.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.6 (/)
X-Debbugs-Envelope-To: 43682
Cc: 43682 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.6 (-)

>>>>> On Mon, 28 Sep 2020 16:37:15 -0700, Eric Abrahamsen <eric@ericabraham=
sen.net> said:

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

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

    Eric> Eric

    Eric> diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
    Eric> index d797e893f5..7f2ebe279e 100644
    Eric> --- a/lisp/gnus/nnimap.el
    Eric> +++ b/lisp/gnus/nnimap.el
    Eric> @@ -407,8 +407,15 @@ nnimap-keepalive
    Eric>  		      (time-subtract
    Eric>  		       now
    Eric>  		       (nnimap-last-command-time nnimap-object))))
    Eric> -            (ignore-errors              ;E.g. "buffer foo has no=
 process".
    Eric> -              (nnimap-send-command "NOOP"))))))))
    Eric> +	    (condition-case err
    Eric> +		(process-send-string "NOOP")
    Eric> +	      (error
    Eric> +	       (if (string-search "has no process" (cdr err))
    Eric> +		   (let ((buf (current-buffer)))
    Eric> +		     (setq nnimap-process-buffers
    Eric> +			   (delq buf nnimap-process-buffers))
    Eric> +		     (kill-buffer buf))
    Eric> +		 (signal (car err) (cdr err)))))))))))

That=CA=BCs not how you call process-send-string, and the
nnimap-send-command is there for a reason: it deals with imap sequence
numbers.

Also I don=CA=BCt think 'has no process' is the only error
'process-send-string' can signal. I see at least 'not running' and
'Output file descriptor.*is closed'

Robert
--=20




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#43682; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 28 Sep 2020 23:37:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 28 19:37:29 2020
Received: from localhost ([127.0.0.1]:54335 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kN2i1-0008DT-Gh
	for submit <at> debbugs.gnu.org; Mon, 28 Sep 2020 19:37:29 -0400
Received: from lists.gnu.org ([209.51.188.17]:32898)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eric@HIDDEN>) id 1kN2hy-0008DL-VH
 for submit <at> debbugs.gnu.org; Mon, 28 Sep 2020 19:37:28 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:45782)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eric@HIDDEN>)
 id 1kN2hy-0008Ss-ES
 for bug-gnu-emacs@HIDDEN; Mon, 28 Sep 2020 19:37:26 -0400
Received: from ericabrahamsen.net ([52.70.2.18]:45092
 helo=mail.ericabrahamsen.net)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eric@HIDDEN>)
 id 1kN2hv-0000um-92
 for bug-gnu-emacs@HIDDEN; Mon, 28 Sep 2020 19:37:25 -0400
Received: from localhost (c-73-254-86-141.hsd1.wa.comcast.net [73.254.86.141])
 (Authenticated sender: eric@HIDDEN)
 by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 802E8FA5B6
 for <bug-gnu-emacs@HIDDEN>; Mon, 28 Sep 2020 23:37:16 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net;
 s=mail; t=1601336236;
 bh=jfVwvFeibR03Yn8azP9qz5FmI0kR5/872YqAiv2FXvM=;
 h=From:To:Subject:Date:From;
 b=LMc8VIM1WbCFe2abrYfHxN5z5OUhch87A70KcXGbQhAR4NbqRWK3s/QLrFIHKa3BU
 WP3kRFtnOCWeeynwL78OI/fwiVDxbJTX78t0MQprP0Ylbj8s7HW94OqUTo6dyFVYIb
 C8i/u3rGEJeHzZBMp/uyFQJmxqI29TfGugXGZyo4=
From: Eric Abrahamsen <eric@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 28.0.50; Clean up nnimap server buffers?
Date: Mon, 28 Sep 2020 16:37:15 -0700
Message-ID: <87eemlh3ro.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=52.70.2.18; envelope-from=eric@HIDDEN;
 helo=mail.ericabrahamsen.net
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/28 19:37:17
X-ACL-Warn: Detected OS   = Linux 2.2.x-3.x [generic] [fuzzy]
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

--=-=-=
Content-Type: text/plain


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


--=-=-=
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..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

--=-=-=--




Acknowledgement sent to Eric Abrahamsen <eric@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#43682; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 29 Sep 2020 15:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.