unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
Subject: Re: auto-revert-mode and tramp file handlers
Date: Thu, 13 May 2004 22:50:21 +0200	[thread overview]
Message-ID: <87ad0cvype.fsf@gmx.de> (raw)
In-Reply-To: <87ad0ekt9z.fsf@emptyhost.emptydomain.de> (Kai Grossjohann's message of "Wed, 12 May 2004 09:18:32 +0200")

Kai Grossjohann <kai@emptydomain.de> writes:

> Luc Teirlinck <teirllm@dms.auburn.edu> 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.

      reply	other threads:[~2004-05-13 20:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-09 17:34 auto-revert-mode and tramp file handlers Luc Teirlinck
2004-05-10 13:17 ` Kai Grossjohann
2004-05-12  2:57   ` Luc Teirlinck
2004-05-12  4:35   ` Luc Teirlinck
2004-05-12  4:45   ` Luc Teirlinck
2004-05-12  7:18     ` Kai Grossjohann
2004-05-13 20:50       ` Michael Albinus [this message]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87ad0cvype.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).