From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel Subject: Re: auto-revert-mode and tramp file handlers Date: Thu, 13 May 2004 22:50:21 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87ad0cvype.fsf@gmx.de> References: <200405091734.i49HYRM01844@raven.dms.auburn.edu> <87isf4zajy.fsf@emptyhost.emptydomain.de> <200405120445.i4C4jle15322@raven.dms.auburn.edu> <87ad0ekt9z.fsf@emptyhost.emptydomain.de> Reply-To: Michael Albinus NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1084481588 7076 80.91.224.253 (13 May 2004 20:53:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 13 May 2004 20:53:08 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu May 13 22:52:56 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BONCK-0007OI-00 for ; Thu, 13 May 2004 22:52:56 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BONCK-0000Qv-00 for ; Thu, 13 May 2004 22:52:56 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BONAh-00079V-Q9 for emacs-devel@quimby.gnus.org; Thu, 13 May 2004 16:51:15 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BONAS-00076M-N2 for emacs-devel@gnu.org; Thu, 13 May 2004 16:51:00 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BON9v-0006t7-BZ for emacs-devel@gnu.org; Thu, 13 May 2004 16:50:58 -0400 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.34) id 1BON9u-0006sF-N9 for emacs-devel@gnu.org; Thu, 13 May 2004 16:50:27 -0400 Original-Received: (qmail 28076 invoked by uid 65534); 13 May 2004 20:50:24 -0000 Original-Received: from pD9E7004B.dip0.t-ipconnect.de (EHLO magdalene) (217.231.0.75) by mail.gmx.net (mp014) with SMTP; 13 May 2004 22:50:24 +0200 X-Authenticated: #3708877 Original-To: emacs-devel@gnu.org In-Reply-To: <87ad0ekt9z.fsf@emptyhost.emptydomain.de> (Kai Grossjohann's message of "Wed, 12 May 2004 09:18:32 +0200") User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:23350 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:23350 Kai Grossjohann writes: > Luc Teirlinck writes: > >> Is there no way that tramp could detect that the user is off line in a >> fraction of a second (as ssh apparently can) and if so, return nil for >> file-exists-p and other functions that expect a return value of nil in >> this case? > > I see what you're talking about. The problem is that Tramp invokes > ssh to connect the remote host, then waits 60 seconds for the shell > prompt. Additionally, it could check whether the process is still > alive and stop waiting when the process dies. I completely forgot to > put this in. The following patch might do the job: magdalene:~/src> diff -u emacs/lisp/net/tramp.el tramp/lisp/tramp.el --- emacs/lisp/net/tramp.el 2004-05-08 22:43:20.000000000 +0200 +++ tramp/lisp/tramp.el 2004-05-13 22:27:19.000000000 +0200 @@ -5025,6 +5025,8 @@ (with-timeout (60 (throw 'tramp-action 'timeout)) (while (not found) (accept-process-output p 1) + (unless (memq (process-status p) '(run open)) + (throw 'tramp-action 'process-died)) (goto-char (point-min)) (setq todo actions) (while todo @@ -5062,6 +5064,8 @@ (with-timeout (60 (throw 'tramp-action 'timeout)) (while (not found) (accept-process-output p 1) + (unless (memq (process-status p) '(run open)) + (throw 'tramp-action 'process-died)) (setq todo actions) (goto-char (point-min)) (while todo @@ -5466,12 +5470,16 @@ (with-timeout (timeout) (while (not found) (accept-process-output proc 1) + (unless (memq (process-status proc) '(run open)) + (error "Process has died")) (goto-char (point-min)) (setq found (when (re-search-forward regexp nil t) (tramp-match-string-list))))))) (t (while (not found) (accept-process-output proc 1) + (unless (memq (process-status proc) '(run open)) + (error "Process has died")) (goto-char (point-min)) (setq found (when (re-search-forward regexp nil t) (tramp-match-string-list)))))) @@ -6079,12 +6087,16 @@ (with-timeout (timeout) (while (not found) (accept-process-output proc 1) + (unless (memq (process-status proc) '(run open)) + (error "Process has died")) (goto-char (point-max)) (forward-line -1) (setq found (looking-at end-of-output)))))) (t (while (not found) (accept-process-output proc 1) + (unless (memq (process-status proc) '(run open)) + (error "Process has died")) (goto-char (point-max)) (forward-line -1) (setq found (looking-at end-of-output)))))) It's not "a fraction of a second", and it just returns with an error in case a connection is broken, but it is better than waiting 60". Silently returning for `file-exists-p' and friends is outstanding. It is really a design question, whether Tramp shall report a broken connection, or whether it should just return. Don't know what's better. Also available in Tramp CVS, together with the recent patch provided by Kai. Best regards, Michael.