tramp-devel
[Top][All Lists]
Advanced

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

Re: tramp (2.0.48); tramp doesn't work with FreeBSD


From: Michael Albinus
Subject: Re: tramp (2.0.48); tramp doesn't work with FreeBSD
Date: Sat, 16 Apr 2005 16:39:53 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Michael Kifer <address@hidden> writes:

> Tramp hangs when visiting directories on a remote FreeBSD machine from a Linux
> machinr. The hangup occurs when Tramp is trying to send tramp_file_attributes:
>
>     tramp: Setting shell prompt
>     tramp: Remote `/bin/sh' groks tilde expansion, good
>     tramp: Finding command to check if file exists
>     tramp: Finding a suitable `ls' command
>     tramp: Checking remote `/bin/ls' command for `-n' option
>     tramp: Testing remote command `/bin/ls' for -n...okay
>     tramp: Using remote command `/bin/ls' for getting directory listings
>     tramp: Finding true name for `/scpx:ug.cs.sunysb.edu:/home/f/kifer/'
>     tramp: Check /home
>     tramp: file attributes with perl: /scpx:ug.cs.sunysb.edu:/home
>     tramp: Sending the Perl script `tramp_file_attributes'...
>
> The same works when tramping to another Linux or Solaris.

After debugging on your machine, I've found the following evidences:

- FreeBSD has a bug in process communication. This is known to Emacs,
  see comment "gross hack" in process.c, function send_process. Emacs
  makes a workaround if it detects this situation, but only if FreeBSD
  is running on the machine Emacs has been compiled.

- Tramp sets tramp-chunksize if it detects hosts with such a buggy
  process communication. Up to now, it has checked the _local_ host
  only. You're running Linux, which is regarded clean.

I've made a patch in tramp.el which checks the _remote_ host,
too. With this patch, I could access your FreeBSD machine via Tramp
without any problem. The patch is appended if you want to test it.

> Moreover, I have another, older copy of Emacs with an earlier Tramp:
>
>     Emacs  : GNU Emacs 21.3.50.1 (i686-pc-linux-gnu, X toolkit)
>     of 2004-08-04 on kiferserv.kiferhome.com
>     Package: tramp (2.0.39)
>
> and tramp does work when visiting files on the same FreeBSD machine.
> The setup is the same in both cases, and the tests were run 1 min
> apart.

Hmm, this sounds like a contradiction to my saying above. But maybe
there has been a change of the send_process bug fix in Emacs as well?

> Hope this can be fixed soon.
>
> Thanks
> michael

Thanks for all your support, and best regards, Michael.

Index: tramp.el
===================================================================
RCS file: /cvsroot/tramp/tramp/lisp/tramp.el,v
retrieving revision 2.359.2.31
diff -u -r2.359.2.31 tramp.el
--- tramp.el    27 Feb 2005 14:28:50 -0000      2.359.2.31
+++ tramp.el    16 Apr 2005 14:38:35 -0000
@@ -1352,7 +1352,9 @@
 
 ;; Chunked sending kluge.  We set this to 500 for black-listed constellations
 ;; known to have a bug in `process-send-string'; some ssh connections appear
-;; to drop bytes when data is sent too quickly.
+;; to drop bytes when data is sent too quickly.  There is also a connection
+;; buffer local variable, which is computed depending on remote host properties
+;; when `tramp-chunksize' is zero or nil.
 (defcustom tramp-chunksize
   (when (and (not (featurep 'xemacs))
             (memq system-type '(hpux)))
@@ -3561,7 +3563,13 @@
            (unless asynchronous
              (tramp-wait-for-output)))
          (unless asynchronous
-           (insert-buffer (tramp-get-buffer multi-method method user host)))
+           ;; We cannot use `insert-buffer' because the tramp buffer
+           ;; changes its contents before insertion due to calling
+           ;; `expand-file' and alike.
+           (insert
+            (with-current-buffer
+                (tramp-get-buffer multi-method method user host)
+              (buffer-string))))
          (when error-buffer
            (save-excursion
              (unless (bufferp error-buffer)
@@ -3571,7 +3579,11 @@
               "cat /tmp/tramp.$$.err")
              (tramp-wait-for-output)
              (set-buffer error-buffer)
-             (insert-buffer (tramp-get-buffer multi-method method user host))
+             ;; Same comment as above
+             (insert
+              (with-current-buffer
+                  (tramp-get-buffer multi-method method user host)
+                (buffer-string)))
              (tramp-send-command-and-check
               multi-method method user host "rm -f /tmp/tramp.$$.err")))
          (save-excursion
@@ -4834,6 +4846,9 @@
 (defun tramp-set-auto-save ()
   (when (and (buffer-file-name)
              (tramp-tramp-file-p (buffer-file-name))
+            ;; ange-ftp has its own auto-save mechanism
+            (eq (tramp-find-foreign-file-name-handler (buffer-file-name))
+                'tramp-sh-file-name-handler)
              auto-save-default)
     (auto-save-mode 1)))
 (add-hook 'find-file-hooks 'tramp-set-auto-save t)
@@ -5417,7 +5432,7 @@
              method))
     (when multi-method
       (error "Cannot multi-connect using telnet connection method"))
-    (tramp-pre-connection multi-method method user host)
+    (tramp-pre-connection multi-method method user host tramp-chunksize)
     (tramp-message 7 "Opening connection for address@hidden using %s..."
                   (or user (user-login-name)) host method)
     (let ((process-environment (copy-sequence process-environment)))
@@ -5475,7 +5490,7 @@
   (save-match-data
     (when multi-method
       (error "Cannot multi-connect using rsh connection method"))
-    (tramp-pre-connection multi-method method user host)
+    (tramp-pre-connection multi-method method user host tramp-chunksize)
     (if (and user (not (string= user "")))
        (tramp-message 7 "Opening connection for address@hidden using %s..."
                       user host method)
@@ -5544,7 +5559,7 @@
       (error
        "Cannot connect to different host `%s' with `su' connection method"
        host))
-    (tramp-pre-connection multi-method method user host)
+    (tramp-pre-connection multi-method method user host tramp-chunksize)
     (tramp-message 7 "Opening connection for `%s' using `%s'..."
                   (or user "<root>") method)
     (let ((process-environment (copy-sequence process-environment)))
@@ -5609,7 +5624,7 @@
     (unless (and (= (length method) (length user))
                  (= (length method) (length host)))
       (error "Arrays METHOD, USER, HOST must have equal length"))
-    (tramp-pre-connection multi-method method user host)
+    (tramp-pre-connection multi-method method user host tramp-chunksize)
     (tramp-message 7 "Opening `%s' connection..." multi-method)
     (let ((process-environment (copy-sequence process-environment)))
       (setenv "TERM" tramp-terminal-type)
@@ -5810,7 +5825,7 @@
 ;; HHH: Not Changed.  This might handle the case where USER is not
 ;;      given in the "File name" very poorly.  Then, the local
 ;;      variable tramp-current-user will be set to nil.
-(defun tramp-pre-connection (multi-method method user host)
+(defun tramp-pre-connection (multi-method method user host chunksize)
   "Do some setup before actually logging in.
 METHOD, USER and HOST specify the connection."
   (set-buffer (tramp-get-buffer multi-method method user host))
@@ -5818,6 +5833,7 @@
   (set (make-local-variable 'tramp-current-method) method)
   (set (make-local-variable 'tramp-current-user)   user)
   (set (make-local-variable 'tramp-current-host)   host)
+  (set (make-local-variable 'tramp-chunksize)      chunksize)
   (set (make-local-variable 'inhibit-eol-conversion) nil)
   (erase-buffer))
 
@@ -5869,6 +5885,20 @@
   (erase-buffer)
   (tramp-send-command-internal multi-method method user host
                               "TERM=dumb; export TERM")
+  (erase-buffer)
+  ;; Check whether the remote host suffers from buggy `send-process-string'.
+  ;; This is known for FreeBSD (see comment in `send_process', file process.c).
+  ;; I've tested sending 624 bytes successfully, sending 625 bytes failed.
+  ;; Emacs makes a hack when this host type is detected locally.  It cannot
+  ;; handle remote hosts, though.
+  (when (or (not tramp-chunksize) (zerop tramp-chunksize))
+    (tramp-message 9 "Checking remote host type for `send-process-string' bug")
+    (tramp-send-command-internal multi-method method user host
+                                "(uname -sr) 2>/dev/null")
+    (goto-char (point-min))
+    (when (looking-at "FreeBSD")
+      (setq tramp-chunksize 500)))
+
   ;; Try to set up the coding system correctly.
   ;; CCC this can't be the right way to do it.  Hm.
   (save-excursion
@@ -7226,7 +7256,6 @@
         tramp-yesno-prompt-regexp
         tramp-yn-prompt-regexp
         tramp-terminal-prompt-regexp
-        tramp-out-of-band-prompt-regexp
         tramp-temp-name-prefix
         tramp-file-name-structure
         tramp-file-name-regexp
@@ -7286,31 +7315,44 @@
 (defun tramp-append-tramp-buffers ()
   "Append Tramp buffers into the bug report."
 
-  ;; We load mml.el from Gnus.
+  ;; We load message.el and mml.el from Gnus.
   (if (featurep 'xemacs)
-      (load "mml" 'noerror)
+      (progn
+       (load "message" 'noerror)
+       (load "mml" 'noerror))
+    (require 'message nil 'noerror)
     (require 'mml nil 'noerror))
+  (when (functionp 'message-mode)
+    (funcall 'message-mode))
+  (when (functionp 'mml-mode)
+    (funcall 'mml-mode t))
 
   (when (and
-        ;; We don't want to add another dependency.
-        (functionp 'mml-insert-empty-tag)
-        ;; 2nd parameter since Emacs 22.
-        (condition-case nil
-            (list-buffers-noselect nil nil)
-          (t nil)))
-    (let ((buffer-list
-          (delq nil
-           (mapcar '(lambda (b)
-            (when (string-match "^\\*\\(debug \\)?tramp/" (buffer-name b)) b))
-            (buffer-list))))
-         (curbuf (current-buffer)))
+        (eq major-mode 'message-mode)
+        (boundp 'mml-mode)
+        (symbol-value 'mml-mode))
+
+    (let* ((tramp-buf-regexp "\\*\\(debug \\)?tramp/")
+          (buffer-list
+           (delq nil
+                 (mapcar '(lambda (b)
+                    (when (string-match tramp-buf-regexp (buffer-name b)) b))
+                         (buffer-list))))
+          (curbuf (current-buffer)))
 
       ;; There is at least one Tramp buffer.
       (when buffer-list
-       (switch-to-buffer (list-buffers-noselect nil buffer-list))
+       (switch-to-buffer (list-buffers-noselect nil))
        (delete-other-windows)
        (setq buffer-read-only nil)
-       (goto-char (point-max))
+       (goto-char (point-min))
+       (while (not (eobp))
+         (if (re-search-forward tramp-buf-regexp (tramp-point-at-eol) t)
+             (forward-line 1)
+           (forward-line 0)
+           (let ((start (point)))
+             (forward-line 1)
+             (kill-region start (point)))))
        (insert "
 The buffer(s) above will be appended to this message.  If you don't want
 to append a buffer because it contains sensible data, or because the buffer

reply via email to

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