emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: auto-revert-mode and tramp file handlers


From: Michael Albinus
Subject: Re: auto-revert-mode and tramp file handlers
Date: Thu, 13 May 2004 22:50:21 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

Kai Grossjohann <address@hidden> writes:

> Luc Teirlinck <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]