diff options
| author | Michael Albinus | 2021-12-09 20:03:16 +0100 |
|---|---|---|
| committer | Michael Albinus | 2021-12-09 20:03:16 +0100 |
| commit | bbfb37378366f28696760153279a2d55b3e8faf9 (patch) | |
| tree | ddd116463741ed86c7738d55de17f60272092d68 | |
| parent | 6ecb24f877242371a0dbc7938e9b408df2690dc7 (diff) | |
| download | emacs-bbfb37378366f28696760153279a2d55b3e8faf9.tar.gz emacs-bbfb37378366f28696760153279a2d55b3e8faf9.zip | |
Improve lock-pid handling in Tramp
* lisp/net/tramp-cache.el: Remove comment.
* lisp/net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection):
* lisp/net/tramp-rclone.el (tramp-rclone-maybe-open-connection):
* lisp/net/tramp-sshfs.el (tramp-sshfs-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-maybe-open-connection):
Do not set "lock-pid" connection-property.
(tramp-sudoedit-handle-delete-file): Use "rm -f".
* lisp/net/tramp.el (tramp-test-message): Extend for buffers w/o
remote default-directory.
(tramp-lock-pid): New defvar.
(tramp-get-lock-pid): Reimplement.
| -rw-r--r-- | lisp/net/tramp-cache.el | 2 | ||||
| -rw-r--r-- | lisp/net/tramp-gvfs.el | 3 | ||||
| -rw-r--r-- | lisp/net/tramp-rclone.el | 4 | ||||
| -rw-r--r-- | lisp/net/tramp-sshfs.el | 3 | ||||
| -rw-r--r-- | lisp/net/tramp-sudoedit.el | 5 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 31 |
6 files changed, 20 insertions, 28 deletions
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el index f2be297d59c..b909c5706d6 100644 --- a/lisp/net/tramp-cache.el +++ b/lisp/net/tramp-cache.el | |||
| @@ -49,8 +49,6 @@ | |||
| 49 | ;; an open connection. Examples: "scripts" keeps shell script | 49 | ;; an open connection. Examples: "scripts" keeps shell script |
| 50 | ;; definitions already sent to the remote shell, "last-cmd-time" is | 50 | ;; definitions already sent to the remote shell, "last-cmd-time" is |
| 51 | ;; the time stamp a command has been sent to the remote process. | 51 | ;; the time stamp a command has been sent to the remote process. |
| 52 | ;; "lock-pid" is the timestamp a (network) process is created, it is | ||
| 53 | ;; used instead of the pid in file locks. | ||
| 54 | ;; | 52 | ;; |
| 55 | ;; - The key is nil. These are temporary properties related to the | 53 | ;; - The key is nil. These are temporary properties related to the |
| 56 | ;; local machine. Examples: "parse-passwd" and "parse-group" keep | 54 | ;; local machine. Examples: "parse-passwd" and "parse-group" keep |
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index d7af0d34bd5..6b0299aa097 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el | |||
| @@ -2125,9 +2125,6 @@ connection if a previous connection has died for some reason." | |||
| 2125 | (process-put p 'vector vec) | 2125 | (process-put p 'vector vec) |
| 2126 | (set-process-query-on-exit-flag p nil) | 2126 | (set-process-query-on-exit-flag p nil) |
| 2127 | 2127 | ||
| 2128 | ;; Mark process for filelock. | ||
| 2129 | (tramp-set-connection-property p "lock-pid" (truncate (time-to-seconds))) | ||
| 2130 | |||
| 2131 | ;; Set connection-local variables. | 2128 | ;; Set connection-local variables. |
| 2132 | (tramp-set-connection-local-variables vec))) | 2129 | (tramp-set-connection-local-variables vec))) |
| 2133 | 2130 | ||
diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el index 09862c6a04c..71ec2607a30 100644 --- a/lisp/net/tramp-rclone.el +++ b/lisp/net/tramp-rclone.el | |||
| @@ -368,10 +368,6 @@ connection if a previous connection has died for some reason." | |||
| 368 | (process-put p 'vector vec) | 368 | (process-put p 'vector vec) |
| 369 | (set-process-query-on-exit-flag p nil) | 369 | (set-process-query-on-exit-flag p nil) |
| 370 | 370 | ||
| 371 | ;; Mark process for filelock. | ||
| 372 | (tramp-set-connection-property | ||
| 373 | p "lock-pid" (truncate (time-to-seconds))) | ||
| 374 | |||
| 375 | ;; Set connection-local variables. | 371 | ;; Set connection-local variables. |
| 376 | (tramp-set-connection-local-variables vec))) | 372 | (tramp-set-connection-local-variables vec))) |
| 377 | 373 | ||
diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el index a19c99316e6..ef1f302546a 100644 --- a/lisp/net/tramp-sshfs.el +++ b/lisp/net/tramp-sshfs.el | |||
| @@ -345,9 +345,6 @@ connection if a previous connection has died for some reason." | |||
| 345 | (process-put p 'vector vec) | 345 | (process-put p 'vector vec) |
| 346 | (set-process-query-on-exit-flag p nil) | 346 | (set-process-query-on-exit-flag p nil) |
| 347 | 347 | ||
| 348 | ;; Mark process for filelock. | ||
| 349 | (tramp-set-connection-property p "lock-pid" (truncate (time-to-seconds))) | ||
| 350 | |||
| 351 | ;; Set connection-local variables. | 348 | ;; Set connection-local variables. |
| 352 | (tramp-set-connection-local-variables vec))) | 349 | (tramp-set-connection-local-variables vec))) |
| 353 | 350 | ||
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index 0309b6b0227..88e8c43534b 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el | |||
| @@ -336,7 +336,7 @@ absolute file names." | |||
| 336 | (if (and delete-by-moving-to-trash trash) | 336 | (if (and delete-by-moving-to-trash trash) |
| 337 | (move-file-to-trash filename) | 337 | (move-file-to-trash filename) |
| 338 | (unless (tramp-sudoedit-send-command | 338 | (unless (tramp-sudoedit-send-command |
| 339 | v "rm" (tramp-compat-file-name-unquote localname)) | 339 | v "rm" "-f" (tramp-compat-file-name-unquote localname)) |
| 340 | ;; Propagate the error. | 340 | ;; Propagate the error. |
| 341 | (with-current-buffer (tramp-get-connection-buffer v) | 341 | (with-current-buffer (tramp-get-connection-buffer v) |
| 342 | (goto-char (point-min)) | 342 | (goto-char (point-min)) |
| @@ -788,9 +788,6 @@ connection if a previous connection has died for some reason." | |||
| 788 | (process-put p 'vector vec) | 788 | (process-put p 'vector vec) |
| 789 | (set-process-query-on-exit-flag p nil) | 789 | (set-process-query-on-exit-flag p nil) |
| 790 | 790 | ||
| 791 | ;; Mark process for filelock. | ||
| 792 | (tramp-set-connection-property p "lock-pid" (truncate (time-to-seconds))) | ||
| 793 | |||
| 794 | ;; Set connection-local variables. | 791 | ;; Set connection-local variables. |
| 795 | (tramp-set-connection-local-variables vec) | 792 | (tramp-set-connection-local-variables vec) |
| 796 | 793 | ||
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 7dddd84e556..6b05dadc0e5 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -2233,10 +2233,14 @@ the resulting error message." | |||
| 2233 | 2233 | ||
| 2234 | (defun tramp-test-message (fmt-string &rest arguments) | 2234 | (defun tramp-test-message (fmt-string &rest arguments) |
| 2235 | "Emit a Tramp message according `default-directory'." | 2235 | "Emit a Tramp message according `default-directory'." |
| 2236 | (if (tramp-tramp-file-p default-directory) | 2236 | (cond |
| 2237 | (apply #'tramp-message | 2237 | ((tramp-tramp-file-p default-directory) |
| 2238 | (tramp-dissect-file-name default-directory) 0 fmt-string arguments) | 2238 | (apply #'tramp-message |
| 2239 | (apply #'message fmt-string arguments))) | 2239 | (tramp-dissect-file-name default-directory) 0 fmt-string arguments)) |
| 2240 | ((tramp-file-name-p (car tramp-current-connection)) | ||
| 2241 | (apply #'tramp-message | ||
| 2242 | (car tramp-current-connection) 0 fmt-string arguments)) | ||
| 2243 | (t (apply #'message fmt-string arguments)))) | ||
| 2240 | 2244 | ||
| 2241 | (put #'tramp-test-message 'tramp-suppress-trace t) | 2245 | (put #'tramp-test-message 'tramp-suppress-trace t) |
| 2242 | 2246 | ||
| @@ -3958,16 +3962,19 @@ Return nil when there is no lockfile." | |||
| 3958 | (insert-file-contents-literally lockname) | 3962 | (insert-file-contents-literally lockname) |
| 3959 | (buffer-string)))))) | 3963 | (buffer-string)))))) |
| 3960 | 3964 | ||
| 3965 | (defvar tramp-lock-pid nil | ||
| 3966 | "A random nunber local for every connection. | ||
| 3967 | Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'") | ||
| 3968 | |||
| 3961 | (defun tramp-get-lock-pid (file) | 3969 | (defun tramp-get-lock-pid (file) |
| 3962 | "Determine pid for lockfile of FILE." | 3970 | "Determine pid for lockfile of FILE." |
| 3963 | ;; Some Tramp methods do not offer a connection process, but just a | 3971 | ;; Not all Tramp methods use an own process. So we use a random |
| 3964 | ;; network process as a place holder. Those processes use the | 3972 | ;; number, which is as good as a process id. |
| 3965 | ;; "lock-pid" connection property as fake pid, in fact it is the | 3973 | (with-current-buffer |
| 3966 | ;; time stamp the process is created. | 3974 | (tramp-get-connection-buffer (tramp-dissect-file-name file)) |
| 3967 | (let ((p (tramp-get-process (tramp-dissect-file-name file)))) | 3975 | (or tramp-lock-pid |
| 3968 | (number-to-string | 3976 | (setq-local |
| 3969 | (or (process-id p) | 3977 | tramp-lock-pid (number-to-string (random most-positive-fixnum)))))) |
| 3970 | (tramp-get-connection-property p "lock-pid" (emacs-pid)))))) | ||
| 3971 | 3978 | ||
| 3972 | (defconst tramp-lock-file-info-regexp | 3979 | (defconst tramp-lock-file-info-regexp |
| 3973 | ;; USER@HOST.PID[:BOOT_TIME] | 3980 | ;; USER@HOST.PID[:BOOT_TIME] |