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#47478: 28.0.50; Provide customization option for nnimap-keepalive-timer Date: Mon, 03 May 2021 09:16:40 -0700 Message-ID: <87r1inu713.fsf@ericabrahamsen.net> References: <87wntqgca7.fsf@ericabrahamsen.net> <87a6pdmxv1.fsf@gnus.org> <87im41ul8w.fsf@ericabrahamsen.net> <87v980chs1.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="29124"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 47478@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 03 18:17:44 2021 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 1ldbGR-0007R7-Md for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 May 2021 18:17:44 +0200 Original-Received: from localhost ([::1]:50240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldbGQ-0004D1-P7 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 May 2021 12:17:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldbFm-0004CW-M0 for bug-gnu-emacs@gnu.org; Mon, 03 May 2021 12:17:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35729) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ldbFm-0003cV-EY for bug-gnu-emacs@gnu.org; Mon, 03 May 2021 12:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ldbFm-0000Dr-B0 for bug-gnu-emacs@gnu.org; Mon, 03 May 2021 12:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 May 2021 16:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47478 X-GNU-PR-Package: emacs Original-Received: via spool by 47478-submit@debbugs.gnu.org id=B47478.1620058611846 (code B ref 47478); Mon, 03 May 2021 16:17:02 +0000 Original-Received: (at 47478) by debbugs.gnu.org; 3 May 2021 16:16:51 +0000 Original-Received: from localhost ([127.0.0.1]:47275 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldbFa-0000Da-VG for submit@debbugs.gnu.org; Mon, 03 May 2021 12:16:51 -0400 Original-Received: from ericabrahamsen.net ([52.70.2.18]:37664 helo=mail.ericabrahamsen.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldbFZ-0000DU-BA for 47478@debbugs.gnu.org; Mon, 03 May 2021 12:16:50 -0400 Original-Received: from localhost (c-71-197-184-122.hsd1.wa.comcast.net [71.197.184.122]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id DA30FFA023; Mon, 3 May 2021 16:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1620058602; bh=OTljn5dZpOPSq/rJ924nt8vKeoX81YvNUaXOIRPxe7s=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=bXexAWx/H5lgXKjEXIYbR9nxQNfKo9wp4fdq8iHvUeagSX7z24zup4fJqBf01Bpkq bfHVrlm+T/2Op/mkl0+li3K09M9DtmNiyr0XpCeaUvBwdIyoCVSwn1lDsYRLYBV+Ej RNXH07UJ+AI327T8u4PWsxj91uEr8G6mj8RVs004= In-Reply-To: <87v980chs1.fsf@gnus.org> (Lars Ingebrigtsen's message of "Mon, 03 May 2021 11:01:50 +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:205530 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > Eric Abrahamsen writes: > >> Cool. In the meantime I've come to prefer the name >> `nnimap-keepalive-intervals', if that's all right. > > Yes, even better. > >> I'll add this to the manual, as well. Do you think it should be a >> defvoo, or a regular customization option? > > Probably a defvoo -- it's possible that people would want different > timeouts for different servers. Cool, here's what it looks like now. Eric --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-new-defvoo-nnimap-keepalive-intervals-to-Gnus-nn.patch >From 6cd184737b8f9318d5a2d2115721b8771436bd13 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Mon, 3 May 2021 09:14:24 -0700 Subject: [PATCH] Add new defvoo nnimap-keepalive-intervals to Gnus nnimap servers * lisp/gnus/nnimap.el (nnimap-keepalive-intervals): New per-server config for customizing when keepalive commands are sent. (nnimap-keepalive, nnimap-open-connection-1): Consult in these places. Additionally, use nnimap-streaming -> t when sending the keepalive NOOP, so we don't wait for the response. * doc/misc/gnus.texi (Customizing the IMAP Connection): Document. --- doc/misc/gnus.texi | 10 ++++++++++ lisp/gnus/nnimap.el | 26 ++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index 869bb27266..71304dc008 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -14515,6 +14515,16 @@ Customizing the IMAP Connection and @samp{INBOX.Lists.emacs}, but you'd like the nnimap group names to be @samp{INBOX} and @samp{Lists.emacs}, you should enable this option. +@item nnimap-keepalive-intervals +By default, nnimap will send occasional ``NOOP'' signals to the +server, to keep the connection alive. This option governs how often +that happens. It is a cons of two integers, representing seconds: +first how often to run the keepalive check, and the second how many +seconds of user inactivity are required to actually send the command. +The default, @code{(900 . 300)}, means run the check every fifteen +minutes and, if the user has been inactive for five minutes, send the +keepalive command. Set to nil to disable keepalive commands altogether. + @end table diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index 8990b2bebe..570be49094 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el @@ -136,6 +136,16 @@ nnimap-fetch-partial-articles likely value would be \"text/\" to automatically fetch all textual parts.") +(defvoo nnimap-keepalive-intervals (cons (* 60 15) + (* 60 5)) + "Configuration for the nnimap keepalive timer. +The value is a cons of two integers (each representing a number +of seconds): the first is how often to run the keepalive +function, the second is the seconds of inactivity required to +send the actual keepalive command. + +Set to nil to disable keepalive commands altogether.") + (defgroup nnimap nil "IMAP for Gnus." :group 'gnus) @@ -405,15 +415,16 @@ nnimap-credentials nil))) (defun nnimap-keepalive () - (let ((now (current-time))) + (let ((now (current-time)) + ;; Set this so we don't wait for a response. + (nnimap-streaming t)) (dolist (buffer nnimap-process-buffers) (when (buffer-live-p buffer) (with-current-buffer buffer (when (and nnimap-object (nnimap-last-command-time nnimap-object) (time-less-p - ;; More than five minutes since the last command. - (* 5 60) + (cdr nnimap-keepalive-intervals) (time-subtract now (nnimap-last-command-time nnimap-object)))) @@ -448,9 +459,12 @@ nnimap-map-port port)) (defun nnimap-open-connection-1 (buffer) - (unless nnimap-keepalive-timer - (setq nnimap-keepalive-timer (run-at-time (* 60 15) (* 60 15) - #'nnimap-keepalive))) + (unless (or nnimap-keepalive-timer + (null nnimap-keepalive-intervals)) + (setq nnimap-keepalive-timer (run-at-time + (car nnimap-keepalive-intervals) + (car nnimap-keepalive-intervals) + #'nnimap-keepalive))) (with-current-buffer (nnimap-make-process-buffer buffer) (let* ((coding-system-for-read 'binary) (coding-system-for-write 'binary) -- 2.31.1 --=-=-=--