From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/65056 Path: news.gmane.org!not-for-mail From: Simon Josefsson Newsgroups: gmane.emacs.gnus.general Subject: Re: closing all inactive server connections Date: Thu, 16 Aug 2007 11:49:22 +0200 Message-ID: <87bqd7vmfx.fsf@mocca.josefsson.org> References: <87zm0tyr2r.fsf@mocca.josefsson.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1187257827 12898 80.91.229.12 (16 Aug 2007 09:50:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 16 Aug 2007 09:50:27 +0000 (UTC) Cc: ding@gnus.org To: Katsumi Yamaoka Original-X-From: ding-owner+M13566@lists.math.uh.edu Thu Aug 16 11:50:24 2007 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.50) id 1ILbzj-0000X4-Ex for ding-account@gmane.org; Thu, 16 Aug 2007 11:50:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1ILbz5-0005pD-JD; Thu, 16 Aug 2007 04:49:43 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1ILbz3-0005os-PJ for ding@lists.math.uh.edu; Thu, 16 Aug 2007 04:49:41 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.67) (envelope-from ) id 1ILbz0-0006BR-KN for ding@lists.math.uh.edu; Thu, 16 Aug 2007 04:49:41 -0500 Original-Received: from yxa.extundo.com ([83.241.177.38]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1ILbyu-0004eV-00 for ; Thu, 16 Aug 2007 11:49:32 +0200 Original-Received: from mocca.josefsson.org (yxa.extundo.com [83.241.177.38]) (authenticated bits=0) by yxa.extundo.com (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id l7G9nM6v006147 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 16 Aug 2007 11:49:23 +0200 OpenPGP: id=B565716F; url=http://josefsson.org/key.txt Mail-Copies-To: nobody X-Hashcash: 1:22:070816:ding@gnus.org::zJya5y38wLCmiFDt:CKLZ X-Hashcash: 1:22:070816:yamaoka@jpl.org::PYau8oDqYdICU75q:jTRU In-Reply-To: (Katsumi Yamaoka's message of "Thu, 16 Aug 2007 16:18:20 +0900") User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux) X-Spam-Status: No, score=-2.3 required=4.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO,SPF_PASS autolearn=ham version=3.1.1 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on yxa-iv X-Virus-Scanned: ClamAV version 0.88.2, clamav-milter version 0.88.2 on yxa.extundo.com X-Virus-Status: Clean X-Spam-Score: -2.5 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:65056 Archived-At: Katsumi Yamaoka writes: >>>>>> Simon Josefsson wrote: >> Katsumi Yamaoka writes: > >>> (while (and (memq (process-status PROCESS) '(open run)) >>> (wait-for-a-string-that-the-PROCESS-returns)) >>> (accept-process-output PROCESS 1) >>> (sit-for 1)) >>> >>> This can be an infinite loop if the process-status keeps `open' >>> or `run' even though the connection has actually died. > >> Can that happen? Wouldn't that be an emacs bug? Shouldn't >> process-status return exit or closed if a connect/process has gone away? > > I meant that the /connection/ is the one between the frontend of > Ted Zlatanov's local network (i.e., VPN) and the IMAP server (see > http://article.gmane.org/gmane.emacs.gnus.general/64906). In his > case, the connection between Emacs and the frontend seems to be > alive even after the connection between the frontend and the IMAP > server dies. So, ideally, what needs to be fixed should be > the VPN program, not be Emacs or Gnus, I think, I agree. The VPN should close the internal connection if the external one is closed. > and the plan I proposed was no more than a workaround. Right. > --- imap.el~ 2007-01-24 07:15:37 +0000 > +++ imap.el 2007-08-16 07:10:13 +0000 > @@ -273,6 +273,14 @@ > :group 'imap > :type 'boolean) > > +(defcustom imap-logout-timeout nil > + "Close server immediately if it can't logout in this number of seconds. > +If it is nil, never close server until logout completes." > + :version "23.0" ;; No Gnus. > + :group 'imap > + :type '(choice (const :tag "No timeout" nil) > + (number :value 1.0))) > + > ;; Various variables. > > (defvar imap-fetch-data-hook nil > @@ -554,7 +562,7 @@ > (not (string-match "failed" response)))) > (setq done process) > (if (memq (process-status process) '(open run)) > - (imap-send-command "LOGOUT")) > + (imap-logout)) > (delete-process process) > nil))))) > done)) > @@ -629,7 +637,7 @@ > (not (string-match "failed" response)))) > (setq done process) > (if (memq (process-status process) '(open run)) > - (imap-send-command "LOGOUT")) > + (imap-logout)) > (delete-process process) > nil))))) > done)) > @@ -1188,7 +1196,7 @@ > (with-current-buffer (or buffer (current-buffer)) > (when (imap-opened) > (condition-case nil > - (imap-send-command-wait "LOGOUT") > + (imap-logout-wait) > (quit nil))) > (when (and imap-process > (memq (process-status imap-process) '(open run))) > @@ -1243,6 +1251,28 @@ > (defun imap-send-command-wait (command &optional buffer) > (imap-wait-for-tag (imap-send-command command buffer) buffer)) > > +(defun imap-logout (&optional buffer) > + (if imap-logout-timeout > + (eval `(with-timeout (imap-logout-timeout > + (condition-case nil > + (with-current-buffer ,(or buffer > + (current-buffer)) > + (delete-process imap-process)) > + (error))) > + (imap-send-command "LOGOUT" buffer))) > + (imap-send-command "LOGOUT" buffer))) > + > +(defun imap-logout-wait (&optional buffer) > + (if imap-logout-timeout > + (eval `(with-timeout (imap-logout-timeout > + (condition-case nil > + (with-current-buffer ,(or buffer > + (current-buffer)) > + (delete-process imap-process)) > + (error))) > + (imap-send-command-wait "LOGOUT" buffer))) > + (imap-send-command-wait "LOGOUT" buffer))) > + > > ;; Mailbox functions: > This looks fine to me, although I haven't tested it. /Simon