Skip to content

Commit

Permalink
Some Tramp adaptions, mainly direct async processes
Browse files Browse the repository at this point in the history
* doc/misc/tramp.texi (Firewalls, Remote processes)
(Frequently Asked Questions): Add @vindex.
(Predefined connection information): Precise precondition or direct
async processes.
(Remote shell setup): Ban ssh RemoteCommand option.
(Frequently Asked Questions): Adapt quoting.

* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.5.1-pre".

* lisp/net/tramp-adb.el (tramp-methods) <adb>: Add `tramp-direct-async'
parameter.
(tramp-adb-handle-make-process): Adapt docstring.

* lisp/net/tramp-sh.el (tramp-methods) <scp, scpx, rsync, ssh, sshx>:
Add `tramp-direct-async' parameter.
(tramp-sh-handle-insert-directory): Simplify merkers.
(tramp-sh-handle-make-process): Adapt docstring.

* lisp/net/tramp.el (tramp-methods): Adapt docstring.
(tramp-debug-message): Suppress lockfiles.
(tramp-test-message): New defun.
(tramp-direct-async-process-p): Check also for `tramp-direct-async'.
(tramp-handle-make-process): Do not check for `tramp-direct-async-args'.

* test/lisp/net/tramp-tests.el (all): Replace `string-match' by
`string-match-p'.
(dired-copy-dereference): Declare.
(tramp-test-temporary-file-directory):
Remove `tramp-direct-async-args` for mock method.
(tramp-test15-copy-directory, tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls): Skip for tramp-rclone.el.
(tramp--test--deftest-direct-async-process): Do not skip for mock
method.
(tramp-test32-shell-command): Adapt test for direct async processes.
(tramp-test36-vc-registered, tramp--test-hpux-p, tramp--test-ksh-p):
Use `tramp-test-vec'.
  • Loading branch information
albinus committed Jan 15, 2021
1 parent 0a26f47 commit 138486c
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 89 deletions.
26 changes: 21 additions & 5 deletions doc/misc/tramp.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1622,6 +1622,7 @@ support this command.

@subsection Tunneling with ssh

@vindex ProxyCommand@r{, ssh option}
With @command{ssh}, you could use the @option{ProxyCommand} entry in
@file{~/.ssh/config}:

Expand Down Expand Up @@ -2056,9 +2057,11 @@ default value is @t{"/data/local/tmp"} for the @option{adb} method,
@item @t{"direct-async-process"}

When this property is non-@code{nil}, an alternative, more performant
implementation of @code{make-process} and
@code{start-file-process} is applied. @ref{Improving performance of
asynchronous remote processes} for a discussion of constraints.
implementation of @code{make-process} and @code{start-file-process} is
applied. The connection method must also be marked with a
non-@code{nil} @code{tramp-direct-async} parameter in
@code{tramp-methods}. @ref{Improving performance of asynchronous
remote processes} for a discussion of constraints.

@item @t{"posix"}

Expand Down Expand Up @@ -2214,6 +2217,11 @@ overwrite this, you might apply

This uses also the settings in @code{tramp-sh-extra-args}.

@vindex RemoteCommand@r{, ssh option}
@strong{Note}: If you use an @option{ssh}-based method for connection,
do @emph{not} set the @option{RemoteCommand} option in your
@command{ssh} configuration, for example to @command{screen}.


@subsection Other remote shell setup hints
@cindex remote shell setup
Expand Down Expand Up @@ -3304,6 +3312,8 @@ whatever reason, then replace @code{(getenv "DISPLAY")} with a
hard-coded, fixed name. Note that using @code{:0} for X11 display name
here will not work as expected.

@vindex ForwardX11@r{, ssh option}
@vindex ForwardX11Trusted@r{, ssh option}
An alternate approach is specify @option{ForwardX11 yes} or
@option{ForwardX11Trusted yes} in @file{~/.ssh/config} on the local
host.
Expand Down Expand Up @@ -3566,6 +3576,7 @@ Furthermore, this approach has the following limitations:
It works only for connection methods defined in @file{tramp-sh.el} and
@file{tramp-adb.el}.

@vindex ControlMaster@r{, ssh option}
@item
It does not support interactive user authentication. With
@option{ssh}-based methods, this can be avoided by using a password
Expand Down Expand Up @@ -4269,6 +4280,7 @@ In order to disable those optimizations, set user option
@item
@value{tramp} does not recognize if a @command{ssh} session hangs

@vindex ServerAliveInterval@r{, ssh option}
@command{ssh} sessions on the local host hang when the network is
down. @value{tramp} cannot safely detect such hangs. The network
configuration for @command{ssh} can be configured to kill such hangs
Expand All @@ -4285,6 +4297,8 @@ Host *
@item
@value{tramp} does not use default @command{ssh} @option{ControlPath}

@vindex ControlPath@r{, ssh option}
@vindex ControlPersist@r{, ssh option}
@value{tramp} overwrites @option{ControlPath} settings when initiating
@command{ssh} sessions. @value{tramp} does this to fend off a stall
if a master session opened outside the Emacs session is no longer
Expand All @@ -4306,8 +4320,8 @@ which allows you to set the @option{ControlPath} provided the variable
@end group
@end lisp

Note how "%r", "%h" and "%p" must be encoded as "%%r", "%%h" and
"%%p".
Note how @samp{%r}, @samp{%h} and @samp{%p} must be encoded as
@samp{%%r}, @samp{%%h} and @samp{%%p}.

@vindex tramp-use-ssh-controlmaster-options
If the @file{~/.ssh/config} is configured appropriately for the above
Expand All @@ -4318,6 +4332,8 @@ this @code{nil} setting:
(customize-set-variable 'tramp-use-ssh-controlmaster-options nil)
@end lisp

@vindex ProxyCommand@r{, ssh option}
@vindex ProxyJump@r{, ssh option}
This shall also be set to @code{nil} if you use the
@option{ProxyCommand} or @option{ProxyJump} options in your
@command{ssh} configuration.
Expand Down
2 changes: 1 addition & 1 deletion doc/misc/trampver.texi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@c In the Tramp GIT, the version numbers are auto-frobbed from
@c tramp.el, and the bug report address is auto-frobbed from
@c configure.ac.
@set trampver 2.5.0
@set trampver 2.5.1-pre
@set trampurl https://www.gnu.org/software/tramp/
@set tramp-bug-report-address tramp-devel@@gnu.org
@set emacsver 25.1
Expand Down
6 changes: 4 additions & 2 deletions lisp/net/tramp-adb.el
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ It is used for TCP/IP devices."
`(,tramp-adb-method
(tramp-login-program ,tramp-adb-program)
(tramp-login-args (("shell")))
(tramp-direct-async t)
(tramp-tmpdir "/data/local/tmp")
(tramp-default-port 5555)))

Expand Down Expand Up @@ -895,8 +896,9 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
;; terminated.
(defun tramp-adb-handle-make-process (&rest args)
"Like `make-process' for Tramp files.
If connection property \"direct-async-process\" is non-nil, an
alternative implementation will be used."
If method parameter `tramp-direct-async' and connection property
\"direct-async-process\" are non-nil, an alternative
implementation will be used."
(if (tramp-direct-async-process-p args)
(apply #'tramp-handle-make-process args)
(when args
Expand Down
17 changes: 10 additions & 7 deletions lisp/net/tramp-sh.el
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ The string is used in `tramp-methods'.")
(tramp-login-args (("-l" "%u") ("-p" "%p") ("%c")
("-e" "none") ("%h")))
(tramp-async-args (("-q")))
(tramp-direct-async t)
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-login ("-l"))
(tramp-remote-shell-args ("-c"))
Expand All @@ -183,6 +184,7 @@ The string is used in `tramp-methods'.")
("-e" "none") ("-t" "-t") ("%h")
("%l")))
(tramp-async-args (("-q")))
(tramp-direct-async t)
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-login ("-l"))
(tramp-remote-shell-args ("-c"))
Expand All @@ -197,6 +199,7 @@ The string is used in `tramp-methods'.")
(tramp-login-args (("-l" "%u") ("-p" "%p") ("%c")
("-e" "none") ("%h")))
(tramp-async-args (("-q")))
(tramp-direct-async t)
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-login ("-l"))
(tramp-remote-shell-args ("-c"))
Expand Down Expand Up @@ -227,6 +230,7 @@ The string is used in `tramp-methods'.")
(tramp-login-args (("-l" "%u") ("-p" "%p") ("%c")
("-e" "none") ("%h")))
(tramp-async-args (("-q")))
(tramp-direct-async t)
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-login ("-l"))
(tramp-remote-shell-args ("-c"))))
Expand All @@ -237,6 +241,7 @@ The string is used in `tramp-methods'.")
("-e" "none") ("-t" "-t") ("%h")
("%l")))
(tramp-async-args (("-q")))
(tramp-direct-async t)
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-login ("-l"))
(tramp-remote-shell-args ("-c"))))
Expand Down Expand Up @@ -2668,11 +2673,9 @@ The method used must be an out-of-band method."
#'file-name-nondirectory (list localname))))
(tramp-get-remote-null-device v))))

(let ((beg-marker (point-marker))
(end-marker (point-marker))
(let ((beg-marker (copy-marker (point) nil))
(end-marker (copy-marker (point) t))
(emc enable-multibyte-characters))
(set-marker-insertion-type beg-marker nil)
(set-marker-insertion-type end-marker t)
;; We cannot use `insert-buffer-substring' because the Tramp
;; buffer changes its contents before insertion due to calling
;; `expand-file-name' and alike.
Expand Down Expand Up @@ -2837,9 +2840,9 @@ the result will be a local, non-Tramp, file name."
;; terminated.
(defun tramp-sh-handle-make-process (&rest args)
"Like `make-process' for Tramp files.
STDERR can also be a file name. If connection property
\"direct-async-process\" is non-nil, an alternative
implementation will be used."
STDERR can also be a file name. If method parameter `tramp-direct-async'
and connection property \"direct-async-process\" are non-nil, an
alternative implementation will be used."
(if (tramp-direct-async-process-p args)
(apply #'tramp-handle-make-process args)
(when args
Expand Down
24 changes: 16 additions & 8 deletions lisp/net/tramp.el
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ pair of the form (KEY VALUE). The following KEYs are defined:
parameters to suppress diagnostic messages, in order not to
tamper the process output.

* `tramp-direct-async-args'
An additional argument when a direct asynchronous process is
started. Used so far only in the \"mock\" method of tramp-tests.el.
* `tramp-direct-async'
Whether the method supports direct asynchronous processes.
Until now, just \"ssh\"-based and \"adb\"-based methods do.

* `tramp-copy-program'
This specifies the name of the program to use for remotely copying
Expand Down Expand Up @@ -1755,7 +1755,8 @@ The outline level is equal to the verbosity of the Tramp message."
Message is formatted with FMT-STRING as control string and the remaining
ARGUMENTS to actually emit the message (if applicable)."
(let ((inhibit-message t)
file-name-handler-alist message-log-max signal-hook-function)
create-lockfiles file-name-handler-alist message-log-max
signal-hook-function)
(with-current-buffer (tramp-get-debug-buffer vec)
(goto-char (point-max))
(let ((point (point)))
Expand Down Expand Up @@ -1982,6 +1983,13 @@ the resulting error message."

(put #'tramp-with-demoted-errors 'tramp-suppress-trace t)

(defun tramp-test-message (fmt-string &rest arguments)
"Emit a Tramp message according `default-directory'."
(if (tramp-tramp-file-p default-directory)
(apply #'tramp-message
(tramp-dissect-file-name default-directory) 0 fmt-string arguments)
(apply #'message fmt-string arguments)))

;; This function provides traces in case of errors not triggered by
;; Tramp functions.
(defun tramp-signal-hook-function (error-symbol data)
Expand Down Expand Up @@ -3741,7 +3749,9 @@ User is always nil."
(let ((v (tramp-dissect-file-name default-directory))
(buffer (plist-get args :buffer))
(stderr (plist-get args :stderr)))
(and ;; It has been indicated.
(and ;; The method supports it.
(tramp-get-method-parameter v 'tramp-direct-async)
;; It has been indicated.
(tramp-get-connection-property v "direct-async-process" nil)
;; There's no multi-hop.
(or (not (tramp-multi-hop-p v))
Expand Down Expand Up @@ -3821,8 +3831,6 @@ It does not support `:stderr'."
(tramp-get-method-parameter v 'tramp-login-args))
(async-args
(tramp-get-method-parameter v 'tramp-async-args))
(direct-async-args
(tramp-get-method-parameter v 'tramp-direct-async-args))
;; We don't create the temporary file. In fact, it
;; is just a prefix for the ControlPath option of
;; ssh; the real temporary file has another name, and
Expand Down Expand Up @@ -3850,7 +3858,7 @@ It does not support `:stderr'."
?h (or host "") ?u (or user "") ?p (or port "")
?c options ?l "")
;; Add arguments for asynchronous processes.
login-args (append async-args direct-async-args login-args)
login-args (append async-args login-args)
;; Expand format spec.
login-args
(tramp-compat-flatten-tree
Expand Down
6 changes: 3 additions & 3 deletions lisp/net/trampver.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
;; Maintainer: Michael Albinus <michael.albinus@gmx.de>
;; Keywords: comm, processes
;; Package: tramp
;; Version: 2.5.0
;; Version: 2.5.1-pre
;; Package-Requires: ((emacs "25.1"))
;; Package-Type: multi
;; URL: https://www.gnu.org/software/tramp/
Expand Down Expand Up @@ -40,7 +40,7 @@
;; ./configure" to change them.

;;;###tramp-autoload
(defconst tramp-version "2.5.0"
(defconst tramp-version "2.5.1-pre"
"This version of Tramp.")

;;;###tramp-autoload
Expand Down Expand Up @@ -76,7 +76,7 @@
;; Check for Emacs version.
(let ((x (if (not (string-lessp emacs-version "25.1"))
"ok"
(format "Tramp 2.5.0 is not fit for %s"
(format "Tramp 2.5.1-pre is not fit for %s"
(replace-regexp-in-string "\n" "" (emacs-version))))))
(unless (string-equal "ok" x) (error "%s" x)))

Expand Down
Loading

0 comments on commit 138486c

Please sign in to comment.