aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2019-01-16 13:56:38 +0100
committerMichael Albinus2019-01-16 13:56:38 +0100
commitb2497ef6952134022ad799247bc5a31f7559ef87 (patch)
tree26deb5515152f01559c3eb971d4d28d61bac6174
parent02976d67369699660add46d548f0d1593885334b (diff)
downloademacs-b2497ef6952134022ad799247bc5a31f7559ef87.tar.gz
emacs-b2497ef6952134022ad799247bc5a31f7559ef87.zip
Some accept-process-output cleanups in Tramp
* lisp/net/tramp.el (tramp-action-out-of-band): Read process output in a loop. (tramp-accept-process-output): Return result. (tramp-interrupt-process): * lisp/net/tramp-adb.el (tramp-adb-parse-device-names): * lisp/net/tramp-rclone.el (tramp-rclone-parse-device-names): Remove FIXME. * lisp/net/tramp-sh.el (tramp-local-coding-commands): Fix docstring. * lisp/net/tramp-smb.el (tramp-smb-wait-for-output): Adapt docstring. Simplify code. * lisp/net/tramp-sudoedit.el (tramp-sudoedit-action-sudo): Adapt docstring. Read process output in a loop. * test/lisp/net/tramp-tests.el (tramp-test43-asynchronous-requests): Remove :unstable tag on emba.
-rw-r--r--lisp/net/tramp-adb.el7
-rw-r--r--lisp/net/tramp-rclone.el3
-rw-r--r--lisp/net/tramp-sh.el8
-rw-r--r--lisp/net/tramp-smb.el45
-rw-r--r--lisp/net/tramp-sudoedit.el7
-rw-r--r--lisp/net/tramp.el21
-rw-r--r--test/lisp/net/tramp-tests.el14
7 files changed, 41 insertions, 64 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index ca47601e4bd..0a357e1ae2f 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -206,7 +206,6 @@ pass to the OPERATION."
206 (tramp-message v 6 "%s" (mapconcat 'identity (process-command p) " ")) 206 (tramp-message v 6 "%s" (mapconcat 'identity (process-command p) " "))
207 (process-put p 'adjust-window-size-function 'ignore) 207 (process-put p 'adjust-window-size-function 'ignore)
208 (set-process-query-on-exit-flag p nil) 208 (set-process-query-on-exit-flag p nil)
209 ;; FIXME: Either remove " 0.1", or comment why it's needed.
210 (while (or (accept-process-output p 0.1) 209 (while (or (accept-process-output p 0.1)
211 (process-live-p p))) 210 (process-live-p p)))
212 (tramp-message v 6 "\n%s" (buffer-string)) 211 (tramp-message v 6 "\n%s" (buffer-string))
@@ -471,7 +470,7 @@ Convert (\"-al\") to (\"-a\" \"-l\"). Remove arguments like \"--dired\"."
471 (apply 'concat 470 (apply 'concat
472 (mapcar (lambda (s) 471 (mapcar (lambda (s)
473 (replace-regexp-in-string 472 (replace-regexp-in-string
474 "\\(.\\)" " -\\1" (replace-regexp-in-string "^-" "" s))) 473 "\\(.\\)" " -\\1" (replace-regexp-in-string "^-" "" s)))
475 ;; FIXME: Warning about removed switches (long and non-dash). 474 ;; FIXME: Warning about removed switches (long and non-dash).
476 (delq nil 475 (delq nil
477 (mapcar 476 (mapcar
@@ -590,7 +589,7 @@ Emacs dired can't find files."
590 (delq 589 (delq
591 nil 590 nil
592 (mapcar 591 (mapcar
593 (lambda (l) (and (not (string-match-p "^[[:space:]]*$" l)) l)) 592 (lambda (l) (and (not (string-match-p "^[[:space:]]*$" l)) l))
594 (split-string (buffer-string) "\n"))))))))))) 593 (split-string (buffer-string) "\n")))))))))))
595 594
596(defun tramp-adb-handle-file-local-copy (filename) 595(defun tramp-adb-handle-file-local-copy (filename)
@@ -1327,7 +1326,7 @@ connection if a previous connection has died for some reason."
1327 ;; Wait for initial prompt. 1326 ;; Wait for initial prompt.
1328 (tramp-adb-wait-for-output p 30) 1327 (tramp-adb-wait-for-output p 30)
1329 (unless (process-live-p p) 1328 (unless (process-live-p p)
1330 (tramp-error vec 'file-error "Terminated!")) 1329 (tramp-error vec 'file-error "Terminated!"))
1331 (process-put p 'vector vec) 1330 (process-put p 'vector vec)
1332 (process-put p 'adjust-window-size-function 'ignore) 1331 (process-put p 'adjust-window-size-function 'ignore)
1333 (set-process-query-on-exit-flag p nil) 1332 (set-process-query-on-exit-flag p nil)
diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el
index 73660572966..f5d184af698 100644
--- a/lisp/net/tramp-rclone.el
+++ b/lisp/net/tramp-rclone.el
@@ -183,7 +183,6 @@ pass to the OPERATION."
183 (tramp-message v 6 "%s" (mapconcat 'identity (process-command p) " ")) 183 (tramp-message v 6 "%s" (mapconcat 'identity (process-command p) " "))
184 (process-put p 'adjust-window-size-function 'ignore) 184 (process-put p 'adjust-window-size-function 'ignore)
185 (set-process-query-on-exit-flag p nil) 185 (set-process-query-on-exit-flag p nil)
186 ;; FIXME: Either remove " 0.1", or comment why it's needed.
187 (while (or (accept-process-output p 0.1) 186 (while (or (accept-process-output p 0.1)
188 (process-live-p p))) 187 (process-live-p p)))
189 (tramp-message v 6 "\n%s" (buffer-string)) 188 (tramp-message v 6 "\n%s" (buffer-string))
@@ -461,7 +460,7 @@ file names."
461 (expand-file-name 460 (expand-file-name
462 (concat 461 (concat
463 tramp-temp-name-prefix (tramp-file-name-method vec) 462 tramp-temp-name-prefix (tramp-file-name-method vec)
464 "." (tramp-file-name-host vec)) 463 "." (tramp-file-name-host vec))
465 (tramp-compat-temporary-file-directory))) 464 (tramp-compat-temporary-file-directory)))
466 465
467(defun tramp-rclone-mounted-p (vec) 466(defun tramp-rclone-mounted-p (vec)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 134ae7a201e..022ecb3d790 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -4340,7 +4340,7 @@ Each item is a list that looks like this:
4340 4340
4341\(FORMAT ENCODING DECODING) 4341\(FORMAT ENCODING DECODING)
4342 4342
4343FORMAT is symbol describing the encoding/decoding format. It can be 4343FORMAT is a symbol describing the encoding/decoding format. It can be
4344`b64' for base64 encoding, `uu' for uu encoding, or `pack' for simple packing. 4344`b64' for base64 encoding, `uu' for uu encoding, or `pack' for simple packing.
4345 4345
4346ENCODING and DECODING can be strings, giving commands, or symbols, 4346ENCODING and DECODING can be strings, giving commands, or symbols,
@@ -4722,7 +4722,7 @@ Goes through the list `tramp-inline-compress-commands'."
4722 (ignore-errors 4722 (ignore-errors
4723 (when (executable-find "ssh") 4723 (when (executable-find "ssh")
4724 (with-tramp-progress-reporter 4724 (with-tramp-progress-reporter
4725 vec 4 "Computing ControlMaster options" 4725 vec 4 "Computing ControlMaster options"
4726 (with-temp-buffer 4726 (with-temp-buffer
4727 (tramp-call-process vec "ssh" nil t nil "-o" "ControlMaster") 4727 (tramp-call-process vec "ssh" nil t nil "-o" "ControlMaster")
4728 (goto-char (point-min)) 4728 (goto-char (point-min))
@@ -5933,5 +5933,9 @@ function cell is returned to be applied on a buffer."
5933;; which could immediately be passed on to the remote side, and 5933;; which could immediately be passed on to the remote side, and
5934;; later on checks the return value of those calls as and when 5934;; later on checks the return value of those calls as and when
5935;; needed. (Stefan Monnier) 5935;; needed. (Stefan Monnier)
5936;;
5937;; * Implement detaching/re-attaching remote sessions. By this, a
5938;; session could be reused after a connection loss. Use dtach, or
5939;; screen, or tmux, or mosh.
5936 5940
5937;;; tramp-sh.el ends here 5941;;; tramp-sh.el ends here
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index abf3248a353..8198930abc6 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -1087,7 +1087,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
1087 ;; Half a year. 1087 ;; Half a year.
1088 (time-since (nth 3 x)) (days-to-time 183)) 1088 (time-since (nth 3 x)) (days-to-time 183))
1089 "%b %e %R" 1089 "%b %e %R"
1090 "%b %e %Y") 1090 "%b %e %Y")
1091 (nth 3 x))))) ; date 1091 (nth 3 x))))) ; date
1092 1092
1093 ;; We mark the file name. The inserted name could be 1093 ;; We mark the file name. The inserted name could be
@@ -2026,54 +2026,25 @@ If ARGUMENT is non-nil, use it as argument for
2026;; We don't use timeouts. If needed, the caller shall wrap around. 2026;; We don't use timeouts. If needed, the caller shall wrap around.
2027(defun tramp-smb-wait-for-output (vec) 2027(defun tramp-smb-wait-for-output (vec)
2028 "Wait for output from smbclient command. 2028 "Wait for output from smbclient command.
2029Returns nil if an error message has appeared." 2029Removes smb prompt. Returns nil if an error message has appeared."
2030 (with-current-buffer (tramp-get-connection-buffer vec) 2030 (with-current-buffer (tramp-get-connection-buffer vec)
2031 (let ((p (get-buffer-process (current-buffer))) 2031 (let ((p (get-buffer-process (current-buffer)))
2032 (found (progn (goto-char (point-min))
2033 (re-search-forward tramp-smb-prompt nil t)))
2034 (err (progn (goto-char (point-min))
2035 (re-search-forward tramp-smb-errors nil t)))
2036 buffer-read-only) 2032 buffer-read-only)
2037 2033
2038 ;; Algorithm: get waiting output. See if last line contains 2034 ;; Read pending output.
2039 ;; `tramp-smb-prompt' sentinel or `tramp-smb-errors' strings. 2035 (while (tramp-accept-process-output p 0.1))
2040 ;; If not, wait a bit and again get waiting output.
2041 ;; FIXME: Either remove " 0.1", or comment why it's needed.
2042 (while (and (not found) (not err)
2043 (or (tramp-accept-process-output p 0.1)
2044 (process-live-p p)))
2045
2046 ;; Search for prompt.
2047 (goto-char (point-min))
2048 (setq found (re-search-forward tramp-smb-prompt nil t))
2049
2050 ;; Search for errors.
2051 (goto-char (point-min))
2052 (setq err (re-search-forward tramp-smb-errors nil t)))
2053
2054 ;; When the process is still alive, read pending output.
2055 ;; FIXME: This loop should be folded into the previous loop.
2056 ;; Also, ERR should be set just once, after the combined
2057 ;; loop has finished.
2058 ;; FIXME: Either remove " 0.1", or comment why it's needed.
2059 (while (and (not found)
2060 (or (tramp-accept-process-output p 0.1)
2061 (process-live-p p)))
2062
2063 ;; Search for prompt.
2064 (goto-char (point-min))
2065 (setq found (re-search-forward tramp-smb-prompt nil t)))
2066
2067 (tramp-message vec 6 "\n%s" (buffer-string)) 2036 (tramp-message vec 6 "\n%s" (buffer-string))
2068 2037
2069 ;; Remove prompt. 2038 ;; Remove prompt.
2070 (when found 2039 (goto-char (point-min))
2040 (when (re-search-forward tramp-smb-prompt nil t)
2071 (goto-char (point-max)) 2041 (goto-char (point-max))
2072 (re-search-backward tramp-smb-prompt nil t) 2042 (re-search-backward tramp-smb-prompt nil t)
2073 (delete-region (point) (point-max))) 2043 (delete-region (point) (point-max)))
2074 2044
2075 ;; Return value is whether no error message has appeared. 2045 ;; Return value is whether no error message has appeared.
2076 (not err)))) 2046 (goto-char (point-min))
2047 (not (re-search-forward tramp-smb-errors nil t)))))
2077 2048
2078(defun tramp-smb-kill-winexe-function () 2049(defun tramp-smb-kill-winexe-function ()
2079 "Send SIGKILL to the winexe process." 2050 "Send SIGKILL to the winexe process."
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el
index e1e5ab091a1..ff3a7d79132 100644
--- a/lisp/net/tramp-sudoedit.el
+++ b/lisp/net/tramp-sudoedit.el
@@ -744,11 +744,10 @@ ID-FORMAT valid values are `string' and `integer'."
744 744
745;; Used in `tramp-sudoedit-sudo-actions'. 745;; Used in `tramp-sudoedit-sudo-actions'.
746(defun tramp-sudoedit-action-sudo (proc vec) 746(defun tramp-sudoedit-action-sudo (proc vec)
747 "Check, whether a sudo process copy has finished." 747 "Check, whether a sudo process has finished.
748Remove unneeded output."
748 ;; There might be pending output for the exit status. 749 ;; There might be pending output for the exit status.
749 ;; FIXME: Either remove " 0.1", or comment why it's needed. 750 (while (tramp-accept-process-output proc 0.1))
750 ;; FIXME: There's a race here. Shouldn't the next two lines be interchanged?
751 (tramp-accept-process-output proc 0.1)
752 (when (not (process-live-p proc)) 751 (when (not (process-live-p proc))
753 ;; Delete narrowed region, it would be in the way reading a Lisp form. 752 ;; Delete narrowed region, it would be in the way reading a Lisp form.
754 (goto-char (point-min)) 753 (goto-char (point-min))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 7632d656a0f..3b235095d37 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3457,7 +3457,7 @@ User is always nil."
3457 start 3457 start
3458 (or (text-property-any start (point-at-eol) 'dired-filename t) 3458 (or (text-property-any start (point-at-eol) 'dired-filename t)
3459 (point-at-eol))) 3459 (point-at-eol)))
3460 (if (= (point-at-bol) (point-at-eol)) 3460 (if (= (point-at-bol) (point-at-eol))
3461 ;; Empty line. 3461 ;; Empty line.
3462 (delete-region (point) (progn (forward-line) (point))) 3462 (delete-region (point) (progn (forward-line) (point)))
3463 (forward-line))))))))) 3463 (forward-line)))))))))
@@ -3977,9 +3977,7 @@ The terminal type can be configured with `tramp-terminal-type'."
3977(defun tramp-action-out-of-band (proc vec) 3977(defun tramp-action-out-of-band (proc vec)
3978 "Check, whether an out-of-band copy has finished." 3978 "Check, whether an out-of-band copy has finished."
3979 ;; There might be pending output for the exit status. 3979 ;; There might be pending output for the exit status.
3980 ;; FIXME: Either remove " 0.1", or comment why it's needed. 3980 (while (tramp-accept-process-output proc 0.1))
3981 ;; FIXME: Shouldn't the following line be wrapped inside (while ...)?
3982 (tramp-accept-process-output proc 0.1)
3983 (cond ((and (not (process-live-p proc)) 3981 (cond ((and (not (process-live-p proc))
3984 (zerop (process-exit-status proc))) 3982 (zerop (process-exit-status proc)))
3985 (tramp-message vec 3 "Process has finished.") 3983 (tramp-message vec 3 "Process has finished.")
@@ -4087,7 +4085,8 @@ for process communication also."
4087 (with-current-buffer (process-buffer proc) 4085 (with-current-buffer (process-buffer proc)
4088 (let (buffer-read-only last-coding-system-used 4086 (let (buffer-read-only last-coding-system-used
4089 ;; We do not want to run timers. 4087 ;; We do not want to run timers.
4090 timer-list timer-idle-list) 4088 timer-list timer-idle-list
4089 result)
4091 ;; Under Windows XP, `accept-process-output' doesn't return 4090 ;; Under Windows XP, `accept-process-output' doesn't return
4092 ;; sometimes. So we add an additional timeout. JUST-THIS-ONE 4091 ;; sometimes. So we add an additional timeout. JUST-THIS-ONE
4093 ;; is set due to Bug#12145. It is an integer, in order to avoid 4092 ;; is set due to Bug#12145. It is an integer, in order to avoid
@@ -4095,9 +4094,10 @@ for process communication also."
4095 (tramp-message 4094 (tramp-message
4096 proc 10 "%s %s %s\n%s" 4095 proc 10 "%s %s %s\n%s"
4097 proc (process-status proc) 4096 proc (process-status proc)
4098 (with-timeout (timeout) 4097 (setq result (with-timeout (timeout)
4099 (accept-process-output proc timeout nil 0)) 4098 (accept-process-output proc timeout nil 0)))
4100 (buffer-string))))) 4099 (buffer-string))
4100 result)))
4101 4101
4102(defun tramp-check-for-regexp (proc regexp) 4102(defun tramp-check-for-regexp (proc regexp)
4103 "Check, whether REGEXP is contained in process buffer of PROC. 4103 "Check, whether REGEXP is contained in process buffer of PROC.
@@ -4641,7 +4641,7 @@ are written with verbosity of 6."
4641It always returns a return code. The Lisp error raised when 4641It always returns a return code. The Lisp error raised when
4642PROGRAM is nil is trapped also, returning 1. Furthermore, traces 4642PROGRAM is nil is trapped also, returning 1. Furthermore, traces
4643are written with verbosity of 6." 4643are written with verbosity of 6."
4644 (let ((default-directory (tramp-compat-temporary-file-directory)) 4644 (let ((default-directory (tramp-compat-temporary-file-directory))
4645 (buffer (if (eq buffer t) (current-buffer) buffer)) 4645 (buffer (if (eq buffer t) (current-buffer) buffer))
4646 result) 4646 result)
4647 (tramp-message 4647 (tramp-message
@@ -4812,7 +4812,7 @@ Only works for Bourne-like shells."
4812 pid) 4812 pid)
4813 ;; If it's a Tramp process, send the INT signal remotely. 4813 ;; If it's a Tramp process, send the INT signal remotely.
4814 (when (and (processp proc) (setq pid (process-get proc 'remote-pid))) 4814 (when (and (processp proc) (setq pid (process-get proc 'remote-pid)))
4815 (if (not (process-live-p proc)) 4815 (if (not (process-live-p proc))
4816 (tramp-error proc 'error "Process %s is not active" proc) 4816 (tramp-error proc 'error "Process %s is not active" proc)
4817 (tramp-message proc 5 "Interrupt process %s with pid %s" proc pid) 4817 (tramp-message proc 5 "Interrupt process %s with pid %s" proc pid)
4818 ;; This is for tramp-sh.el. Other backends do not support this (yet). 4818 ;; This is for tramp-sh.el. Other backends do not support this (yet).
@@ -4824,7 +4824,6 @@ Only works for Bourne-like shells."
4824 ;; fall back to the default implementation. 4824 ;; fall back to the default implementation.
4825 (with-timeout (1 (ignore)) 4825 (with-timeout (1 (ignore))
4826 ;; We cannot run `tramp-accept-process-output', it blocks timers. 4826 ;; We cannot run `tramp-accept-process-output', it blocks timers.
4827 ;; FIXME: Either remove " 0.1", or comment why it's needed.
4828 (while (or (accept-process-output proc 0.1) 4827 (while (or (accept-process-output proc 0.1)
4829 (process-live-p proc))) 4828 (process-live-p proc)))
4830 ;; Report success. 4829 ;; Report success.
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index ff63dc18fbc..28935062864 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -405,7 +405,7 @@ handled properly. BODY shall not contain a timeout."
405 tramp-default-user-alist 405 tramp-default-user-alist
406 tramp-default-host-alist 406 tramp-default-host-alist
407 ;; Suppress check for multihops. 407 ;; Suppress check for multihops.
408 (tramp-cache-data (make-hash-table :test 'equal)) 408 (tramp-cache-data (make-hash-table :test 'equal))
409 (tramp-connection-properties '((nil "login-program" t)))) 409 (tramp-connection-properties '((nil "login-program" t))))
410 ;; Expand `tramp-default-user' and `tramp-default-host'. 410 ;; Expand `tramp-default-user' and `tramp-default-host'.
411 (should (string-equal 411 (should (string-equal
@@ -844,7 +844,7 @@ handled properly. BODY shall not contain a timeout."
844 tramp-default-user-alist 844 tramp-default-user-alist
845 tramp-default-host-alist 845 tramp-default-host-alist
846 ;; Suppress check for multihops. 846 ;; Suppress check for multihops.
847 (tramp-cache-data (make-hash-table :test 'equal)) 847 (tramp-cache-data (make-hash-table :test 'equal))
848 (tramp-connection-properties '((nil "login-program" t))) 848 (tramp-connection-properties '((nil "login-program" t)))
849 (syntax tramp-syntax)) 849 (syntax tramp-syntax))
850 (unwind-protect 850 (unwind-protect
@@ -1168,7 +1168,7 @@ handled properly. BODY shall not contain a timeout."
1168 tramp-default-user-alist 1168 tramp-default-user-alist
1169 tramp-default-host-alist 1169 tramp-default-host-alist
1170 ;; Suppress check for multihops. 1170 ;; Suppress check for multihops.
1171 (tramp-cache-data (make-hash-table :test 'equal)) 1171 (tramp-cache-data (make-hash-table :test 'equal))
1172 (tramp-connection-properties '((nil "login-program" t))) 1172 (tramp-connection-properties '((nil "login-program" t)))
1173 (syntax tramp-syntax)) 1173 (syntax tramp-syntax))
1174 (unwind-protect 1174 (unwind-protect
@@ -5212,7 +5212,13 @@ Use the `ls' command."
5212 "Check parallel asynchronous requests. 5212 "Check parallel asynchronous requests.
5213Such requests could arrive from timers, process filters and 5213Such requests could arrive from timers, process filters and
5214process sentinels. They shall not disturb each other." 5214process sentinels. They shall not disturb each other."
5215 :tags '(:expensive-test :unstable) 5215 ;; The test fails from time to time, w/o a reproducible pattern. So
5216 ;; we mark it as unstable.
5217 ;; Recent investigations have uncovered a race condition in
5218 ;; `accept-process-output'. Let's check on emba, whether this has
5219 ;; been solved.
5220 :tags
5221 (if (getenv "EMACS_EMBA_CI") '(:expensive-test) '(:expensive-test :unstable))
5216 (skip-unless (tramp--test-enabled)) 5222 (skip-unless (tramp--test-enabled))
5217 (skip-unless (tramp--test-sh-p)) 5223 (skip-unless (tramp--test-sh-p))
5218 5224