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, 29 Mar 2021 09:22:40 -0700 Message-ID: <87wntqgca7.fsf@ericabrahamsen.net> 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="9133"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: 47478@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 29 18:23:23 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 1lQufi-0002HK-AQ for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 29 Mar 2021 18:23:22 +0200 Original-Received: from localhost ([::1]:34098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQufh-0000Ed-6T for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 29 Mar 2021 12:23:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQufO-0000DI-RN for bug-gnu-emacs@gnu.org; Mon, 29 Mar 2021 12:23:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37861) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lQufO-0000mI-Io for bug-gnu-emacs@gnu.org; Mon, 29 Mar 2021 12:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lQufO-0003L0-ED for bug-gnu-emacs@gnu.org; Mon, 29 Mar 2021 12:23: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, 29 Mar 2021 16:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 47478 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161703497512802 (code B ref -1); Mon, 29 Mar 2021 16:23:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Mar 2021 16:22:55 +0000 Original-Received: from localhost ([127.0.0.1]:49407 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lQufH-0003KQ-FC for submit@debbugs.gnu.org; Mon, 29 Mar 2021 12:22:55 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:35272) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lQufE-0003KF-Gm for submit@debbugs.gnu.org; Mon, 29 Mar 2021 12:22:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQufE-0008UZ-3s for bug-gnu-emacs@gnu.org; Mon, 29 Mar 2021 12:22:52 -0400 Original-Received: from ericabrahamsen.net ([52.70.2.18]:40694 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 ) id 1lQufC-0000cf-4v for bug-gnu-emacs@gnu.org; Mon, 29 Mar 2021 12:22:51 -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 1F4B6FA099 for ; Mon, 29 Mar 2021 16:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1617034962; bh=INqnRVumzspDoT2vVNqwRtZJ4zJRXprG3c7U5A6IrfY=; h=From:To:Subject:Date:From; b=NieMz/UigIGKia2VE9hDxSKtbCEkFmYFRIWky5lCeN3dnLR8sW5TjERf2lPTrv7CK VXCFoHkqic6TVnVHSdBMkceHWUqFYq+f9RUUQX+pVE9akStchGPXwjX0GFS5fviuNE APOyfCGhggcs9bRM3N9DhShRD5HuJnA8xw8O9C/k= Received-SPF: pass client-ip=52.70.2.18; envelope-from=eric@ericabrahamsen.net; helo=mail.ericabrahamsen.net 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-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:203255 Archived-At: --=-=-= Content-Type: text/plain Bob Newell requested the ability to customize the `nnimap-keepalive-timer', and I've opened this bug report with a patch that adds a new `nnimap-keepalive-times' customization option. It lets you customize both function interval and period of inactivity, or you can set it to nil to disable the keepalive altogether. I also sneaked in a little extra change: since we provided the option to use Dbus to close Gnus servers when your machine is going to sleep, I've noticed that sometimes (more often than you'd think) I seem to be sleeping the machine in between sending the keepalive NOOP and receiving the response. When the computer wakes, Emacs is hung while Gnus waits on an OK that isn't coming, and I need to C-g to get out of it. I would have thought this was a pretty small target to hit, particular since my imap servers are all on this computer, but it happens quite often. So this patch also lets `nnimap-streaming' to t around the keepalive command, so we don't wait for the response. Semantically incorrect, but the effect is right. If this is acceptable I can add a NEWS entry (and maybe the manual as well?). Eric --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=nnimap-keepalive-customization.diff diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index 93e1c47be7..7017bf192e 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el @@ -156,6 +156,24 @@ nnimap-split-download-body :version "28.1" :type 'boolean) +(defcustom nnimap-keepalive-times (cons (* 60 15) + (* 5 60)) + "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. + +For example, the default (900 . 300) means to 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." + :version "28.1" + :type '(choice (const :tag "disable" nil) + (cons (integer :tag "timer interval") + (integer :tag "seconds of inactivity")))) + (defvar nnimap--split-download-body nil "Like `nnimap-split-download-body', but for internal use.") @@ -405,15 +423,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-times) (time-subtract now (nnimap-last-command-time nnimap-object)))) @@ -447,8 +466,10 @@ 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) + (unless (or nnimap-keepalive-timer + (null nnimap-keepalive-times)) + (setq nnimap-keepalive-timer (run-at-time (car nnimap-keepalive-times) + (car nnimap-keepalive-times) #'nnimap-keepalive))) (with-current-buffer (nnimap-make-process-buffer buffer) (let* ((coding-system-for-read 'binary) --=-=-=--