Gnus development mailing list
 help / color / mirror / Atom feed
From: Simon Josefsson <simon@josefsson.org>
To: Katsumi Yamaoka <yamaoka@jpl.org>
Cc: ding@gnus.org
Subject: Re: closing all inactive server connections
Date: Thu, 16 Aug 2007 11:49:22 +0200	[thread overview]
Message-ID: <87bqd7vmfx.fsf@mocca.josefsson.org> (raw)
In-Reply-To: <b4meji4ne0z.fsf@jpl.org> (Katsumi Yamaoka's message of "Thu, 16 Aug 2007 16:18:20 +0900")

Katsumi Yamaoka <yamaoka@jpl.org> writes:

>>>>>> Simon Josefsson wrote:
>> Katsumi Yamaoka <yamaoka@jpl.org> 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)))
> +
>  \f
>  ;; Mailbox functions:
>  

This looks fine to me, although I haven't tested it.

/Simon



  parent reply	other threads:[~2007-08-16  9:49 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-07 15:59 Ted Zlatanov
2007-07-10 19:54 ` Ted Zlatanov
2007-07-19 13:46   ` Ted Zlatanov
2007-07-27 17:06     ` Ted Zlatanov
2007-07-28  0:18       ` Ted Zlatanov
2007-07-30  6:22         ` Katsumi Yamaoka
2007-07-30 15:39           ` Ted Zlatanov
2007-07-31  2:57             ` Katsumi Yamaoka
2007-07-31  3:08               ` Katsumi Yamaoka
2007-07-31  3:19                 ` Ted Zlatanov
2007-07-31  8:52                   ` Katsumi Yamaoka
2007-08-02 19:51                     ` Ted Zlatanov
2007-08-15 11:28                     ` Simon Josefsson
2007-08-16  7:18                       ` Katsumi Yamaoka
2007-08-16  7:25                         ` Katsumi Yamaoka
2007-08-16  9:49                         ` Simon Josefsson [this message]
2007-08-16 15:35                           ` Ted Zlatanov
2007-08-16 15:32                       ` Ted Zlatanov
2007-08-16 15:56                         ` Ted Zlatanov
2007-08-16 23:19                           ` Katsumi Yamaoka
2007-08-16 23:25                             ` Ted Zlatanov
2007-08-16 23:47                               ` Katsumi Yamaoka
2007-08-17 11:09                                 ` Katsumi Yamaoka
2007-09-10 14:52                                   ` Ted Zlatanov
2007-08-15 18:28                     ` Reiner Steib
2007-07-31  3:16               ` Ted Zlatanov
2007-07-31  3:19                 ` Katsumi Yamaoka
2007-07-31  2:58             ` untabify Lisp sources (was Re: closing all inactive server connections) Katsumi Yamaoka
2007-07-31 22:05               ` untabify Lisp sources Reiner Steib
2007-08-01  2:44                 ` Ted Zlatanov
2007-07-31 22:57               ` Miles Bader
2007-08-01  2:46                 ` Ted Zlatanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bqd7vmfx.fsf@mocca.josefsson.org \
    --to=simon@josefsson.org \
    --cc=ding@gnus.org \
    --cc=yamaoka@jpl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).