aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2013-09-10 09:45:33 +0200
committerMichael Albinus2013-09-10 09:45:33 +0200
commit6480194ca1080908a32fb2eb700f3dcf938972d5 (patch)
tree532710ee8dd0e57c83635c5a6b71b153bb12d1da
parent9a2c9b476440268e8d6fbacfec52865a76a8b395 (diff)
downloademacs-6480194ca1080908a32fb2eb700f3dcf938972d5.tar.gz
emacs-6480194ca1080908a32fb2eb700f3dcf938972d5.zip
* net/tramp.el (tramp-cleanup): Remove. Functionality added to
`tramp-cleanup-connection'. * net/tramp-cmds.el (tramp-cleanup-connection): Add optional parameters KEEP-DEBUG and KEEP-PASSWORD. * net/tramp.el (tramp-file-name-handler): * net/tramp-adb.el (tramp-adb-maybe-open-connection): * net/tramp-sh.el (tramp-open-connection-setup-interactive-shell) (tramp-maybe-open-connection): * net/tramp-smb.el (tramp-smb-maybe-open-connection): Use `tramp-cleanup-connection'. * net/tramp-sh.el (tramp-maybe-open-connection): Catch 'uname-changed inside the progress reporter.
-rw-r--r--lisp/ChangeLog18
-rw-r--r--lisp/net/tramp-adb.el2
-rw-r--r--lisp/net/tramp-cmds.el14
-rw-r--r--lisp/net/tramp-sh.el135
-rw-r--r--lisp/net/tramp-smb.el4
-rw-r--r--lisp/net/tramp.el15
6 files changed, 100 insertions, 88 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c3f6e8860d9..fc73e563883 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,21 @@
12013-09-10 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp.el (tramp-cleanup): Remove. Functionality added to
4 `tramp-cleanup-connection'.
5
6 * net/tramp-cmds.el (tramp-cleanup-connection): Add optional
7 parameters KEEP-DEBUG and KEEP-PASSWORD.
8
9 * net/tramp.el (tramp-file-name-handler):
10 * net/tramp-adb.el (tramp-adb-maybe-open-connection):
11 * net/tramp-sh.el (tramp-open-connection-setup-interactive-shell)
12 (tramp-maybe-open-connection):
13 * net/tramp-smb.el (tramp-smb-maybe-open-connection): Use
14 `tramp-cleanup-connection'.
15
16 * net/tramp-sh.el (tramp-maybe-open-connection): Catch
17 'uname-changed inside the progress reporter.
18
12013-09-10 Glenn Morris <rgm@gnu.org> 192013-09-10 Glenn Morris <rgm@gnu.org>
2 20
3 * simple.el (read-minibuffer): Unbreak it. (Bug#15318) 21 * simple.el (read-minibuffer): Unbreak it. (Bug#15318)
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 66d29cb3c8c..595037ab943 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -1153,11 +1153,11 @@ connection if a previous connection has died for some reason."
1153 (read (current-buffer)))))) 1153 (read (current-buffer))))))
1154 (when (and (stringp old-getprop) 1154 (when (and (stringp old-getprop)
1155 (not (string-equal old-getprop new-getprop))) 1155 (not (string-equal old-getprop new-getprop)))
1156 (tramp-cleanup vec)
1157 (tramp-message 1156 (tramp-message
1158 vec 3 1157 vec 3
1159 "Connection reset, because remote host changed from `%s' to `%s'" 1158 "Connection reset, because remote host changed from `%s' to `%s'"
1160 old-getprop new-getprop) 1159 old-getprop new-getprop)
1160 (tramp-cleanup-connection vec t)
1161 (tramp-adb-maybe-open-connection vec))) 1161 (tramp-adb-maybe-open-connection vec)))
1162 1162
1163 ;; Change user if indicated. 1163 ;; Change user if indicated.
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index de06cd5cbc9..5015929534d 100644
--- a/lisp/net/tramp-cmds.el
+++ b/lisp/net/tramp-cmds.el
@@ -55,9 +55,11 @@
55 (buffer-list)))) 55 (buffer-list))))
56 56
57;;;###tramp-autoload 57;;;###tramp-autoload
58(defun tramp-cleanup-connection (vec) 58(defun tramp-cleanup-connection (vec &optional keep-debug keep-password)
59 "Flush all connection related objects. 59 "Flush all connection related objects.
60This includes password cache, file cache, connection cache, buffers. 60This includes password cache, file cache, connection cache,
61buffers. KEEP-DEBUG non-nil preserves the debug buffer.
62KEEP-PASSWORD non-nil preserves the password cache.
61When called interactively, a Tramp connection has to be selected." 63When called interactively, a Tramp connection has to be selected."
62 (interactive 64 (interactive
63 ;; When interactive, select the Tramp remote identification. 65 ;; When interactive, select the Tramp remote identification.
@@ -80,14 +82,15 @@ When called interactively, a Tramp connection has to be selected."
80 "Enter Tramp connection: " connections nil t 82 "Enter Tramp connection: " connections nil t
81 (try-completion "" connections))) 83 (try-completion "" connections)))
82 (when (and name (file-remote-p name)) 84 (when (and name (file-remote-p name))
83 (with-parsed-tramp-file-name name nil v)))))) 85 (with-parsed-tramp-file-name name nil v))))
86 nil nil))
84 87
85 (if (not vec) 88 (if (not vec)
86 ;; Nothing to do. 89 ;; Nothing to do.
87 (message "No Tramp connection found.") 90 (message "No Tramp connection found.")
88 91
89 ;; Flush password cache. 92 ;; Flush password cache.
90 (tramp-clear-passwd vec) 93 (unless keep-password (tramp-clear-passwd vec))
91 94
92 ;; Flush file cache. 95 ;; Flush file cache.
93 (tramp-flush-directory-property vec "") 96 (tramp-flush-directory-property vec "")
@@ -101,7 +104,8 @@ When called interactively, a Tramp connection has to be selected."
101 ;; Remove buffers. 104 ;; Remove buffers.
102 (dolist 105 (dolist
103 (buf (list (get-buffer (tramp-buffer-name vec)) 106 (buf (list (get-buffer (tramp-buffer-name vec))
104 (get-buffer (tramp-debug-buffer-name vec)) 107 (unless keep-debug
108 (get-buffer (tramp-debug-buffer-name vec)))
105 (tramp-get-connection-property vec "process-buffer" nil))) 109 (tramp-get-connection-property vec "process-buffer" nil)))
106 (when (bufferp buf) (kill-buffer buf))))) 110 (when (bufferp buf) (kill-buffer buf)))))
107 111
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 2b7c43a4995..f91cbb29a1d 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3805,11 +3805,12 @@ process to set up. VEC specifies the connection."
3805 vec "uname" 3805 vec "uname"
3806 (tramp-send-command-and-read vec "echo \\\"`uname -sr`\\\"")))) 3806 (tramp-send-command-and-read vec "echo \\\"`uname -sr`\\\""))))
3807 (when (and (stringp old-uname) (not (string-equal old-uname new-uname))) 3807 (when (and (stringp old-uname) (not (string-equal old-uname new-uname)))
3808 (tramp-cleanup vec)
3809 (tramp-message 3808 (tramp-message
3810 vec 3 3809 vec 3
3811 "Connection reset, because remote host changed from `%s' to `%s'" 3810 "Connection reset, because remote host changed from `%s' to `%s'"
3812 old-uname new-uname) 3811 old-uname new-uname)
3812 ;; We want to keep the password.
3813 (tramp-cleanup-connection vec t t)
3813 (throw 'uname-changed (tramp-maybe-open-connection vec)))) 3814 (throw 'uname-changed (tramp-maybe-open-connection vec))))
3814 3815
3815 ;; Check whether the remote host suffers from buggy 3816 ;; Check whether the remote host suffers from buggy
@@ -4287,68 +4288,68 @@ Does not do anything if a connection is already open, but re-opens the
4287connection if a previous connection has died for some reason." 4288connection if a previous connection has died for some reason."
4288 (tramp-check-proper-host vec) 4289 (tramp-check-proper-host vec)
4289 4290
4290 (catch 'uname-changed 4291 (let ((p (tramp-get-connection-process vec))
4291 (let ((p (tramp-get-connection-process vec)) 4292 (process-name (tramp-get-connection-property vec "process-name" nil))
4292 (process-name (tramp-get-connection-property vec "process-name" nil)) 4293 (process-environment (copy-sequence process-environment))
4293 (process-environment (copy-sequence process-environment)) 4294 (pos (with-current-buffer (tramp-get-connection-buffer vec) (point))))
4294 (pos (with-current-buffer (tramp-get-connection-buffer vec) (point)))) 4295
4295 4296 ;; If Tramp opens the same connection within a short time frame,
4296 ;; If Tramp opens the same connection within a short time frame, 4297 ;; there is a problem. We shall signal this.
4297 ;; there is a problem. We shall signal this. 4298 (unless (or (and p (processp p) (memq (process-status p) '(run open)))
4298 (unless (or (and p (processp p) (memq (process-status p) '(run open))) 4299 (not (equal (butlast (append vec nil) 2)
4299 (not (equal (butlast (append vec nil) 2) 4300 (car tramp-current-connection)))
4300 (car tramp-current-connection))) 4301 (> (tramp-time-diff
4301 (> (tramp-time-diff 4302 (current-time) (cdr tramp-current-connection))
4302 (current-time) (cdr tramp-current-connection)) 4303 (or tramp-connection-min-time-diff 0)))
4303 (or tramp-connection-min-time-diff 0))) 4304 (throw 'suppress 'suppress))
4304 (throw 'suppress 'suppress)) 4305
4305 4306 ;; If too much time has passed since last command was sent, look
4306 ;; If too much time has passed since last command was sent, look 4307 ;; whether process is still alive. If it isn't, kill it. When
4307 ;; whether process is still alive. If it isn't, kill it. When 4308 ;; using ssh, it can sometimes happen that the remote end has hung
4308 ;; using ssh, it can sometimes happen that the remote end has 4309 ;; up but the local ssh client doesn't recognize this until it
4309 ;; hung up but the local ssh client doesn't recognize this until 4310 ;; tries to send some data to the remote end. So that's why we
4310 ;; it tries to send some data to the remote end. So that's why 4311 ;; try to send a command from time to time, then look again
4311 ;; we try to send a command from time to time, then look again 4312 ;; whether the process is really alive.
4312 ;; whether the process is really alive. 4313 (condition-case nil
4313 (condition-case nil 4314 (when (and (> (tramp-time-diff
4314 (when (and (> (tramp-time-diff 4315 (current-time)
4315 (current-time) 4316 (tramp-get-connection-property
4316 (tramp-get-connection-property 4317 p "last-cmd-time" '(0 0 0)))
4317 p "last-cmd-time" '(0 0 0))) 4318 60)
4318 60) 4319 p (processp p) (memq (process-status p) '(run open)))
4319 p (processp p) (memq (process-status p) '(run open))) 4320 (tramp-send-command vec "echo are you awake" t t)
4320 (tramp-send-command vec "echo are you awake" t t) 4321 (unless (and (memq (process-status p) '(run open))
4321 (unless (and (memq (process-status p) '(run open)) 4322 (tramp-wait-for-output p 10))
4322 (tramp-wait-for-output p 10)) 4323 ;; The error will be caught locally.
4323 ;; The error will be caught locally. 4324 (tramp-error vec 'file-error "Awake did fail")))
4324 (tramp-error vec 'file-error "Awake did fail"))) 4325 (file-error
4325 (file-error 4326 (tramp-cleanup-connection vec t)
4326 (tramp-cleanup vec) 4327 (setq p nil)))
4327 (setq p nil))) 4328
4328 4329 ;; New connection must be opened.
4329 ;; New connection must be opened. 4330 (condition-case err
4330 (condition-case err 4331 (unless (and p (processp p) (memq (process-status p) '(run open)))
4331 (unless (and p (processp p) (memq (process-status p) '(run open))) 4332
4332 4333 ;; We call `tramp-get-buffer' in order to get a debug buffer
4333 ;; We call `tramp-get-buffer' in order to get a debug 4334 ;; for messages from the beginning.
4334 ;; buffer for messages from the beginning. 4335 (tramp-get-buffer vec)
4335 (tramp-get-buffer vec) 4336
4336 4337 ;; If `non-essential' is non-nil, don't reopen a new connection.
4337 ;; If `non-essential' is non-nil, don't reopen a new connection. 4338 (when (and (boundp 'non-essential) (symbol-value 'non-essential))
4338 (when (and (boundp 'non-essential) (symbol-value 'non-essential)) 4339 (throw 'non-essential 'non-essential))
4339 (throw 'non-essential 'non-essential)) 4340
4340 4341 (with-tramp-progress-reporter
4341 (with-tramp-progress-reporter 4342 vec 3
4342 vec 3 4343 (if (zerop (length (tramp-file-name-user vec)))
4343 (if (zerop (length (tramp-file-name-user vec))) 4344 (format "Opening connection for %s using %s"
4344 (format "Opening connection for %s using %s"
4345 (tramp-file-name-host vec)
4346 (tramp-file-name-method vec))
4347 (format "Opening connection for %s@%s using %s"
4348 (tramp-file-name-user vec)
4349 (tramp-file-name-host vec) 4345 (tramp-file-name-host vec)
4350 (tramp-file-name-method vec))) 4346 (tramp-file-name-method vec))
4347 (format "Opening connection for %s@%s using %s"
4348 (tramp-file-name-user vec)
4349 (tramp-file-name-host vec)
4350 (tramp-file-name-method vec)))
4351 4351
4352 (catch 'uname-changed
4352 ;; Start new process. 4353 ;; Start new process.
4353 (when (and p (processp p)) 4354 (when (and p (processp p))
4354 (delete-process p)) 4355 (delete-process p))
@@ -4503,13 +4504,13 @@ connection if a previous connection has died for some reason."
4503 target-alist (cdr target-alist))) 4504 target-alist (cdr target-alist)))
4504 4505
4505 ;; Make initial shell settings. 4506 ;; Make initial shell settings.
4506 (tramp-open-connection-setup-interactive-shell p vec)))) 4507 (tramp-open-connection-setup-interactive-shell p vec)))))
4507 4508
4508 ;; When the user did interrupt, we must cleanup. 4509 ;; When the user did interrupt, we must cleanup.
4509 (quit 4510 (quit
4510 (tramp-cleanup vec) 4511 (tramp-cleanup-connection vec t)
4511 ;; Propagate the quit signal. 4512 ;; Propagate the quit signal.
4512 (signal (car err) (cdr err))))))) 4513 (signal (car err) (cdr err))))))
4513 4514
4514(defun tramp-send-command (vec command &optional neveropen nooutput) 4515(defun tramp-send-command (vec command &optional neveropen nooutput)
4515 "Send the COMMAND to connection VEC. 4516 "Send the COMMAND to connection VEC.
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 1d4880a9f32..27f3bd41e9c 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -1726,8 +1726,10 @@ If ARGUMENT is non-nil, use it as argument for
1726 (search-forward-regexp 1726 (search-forward-regexp
1727 tramp-smb-wrong-passwd-regexp nil t)) 1727 tramp-smb-wrong-passwd-regexp nil t))
1728 ;; Disable `auth-source' and `password-cache'. 1728 ;; Disable `auth-source' and `password-cache'.
1729 (tramp-message
1730 vec 3 "Retry connection with new password")
1729 (let (auth-sources) 1731 (let (auth-sources)
1730 (tramp-cleanup vec) 1732 (tramp-cleanup-connection vec t)
1731 (tramp-smb-maybe-open-connection vec argument)) 1733 (tramp-smb-maybe-open-connection vec argument))
1732 ;; Propagate the error. 1734 ;; Propagate the error.
1733 (signal (car err) (cdr err))))))))))))) 1735 (signal (car err) (cdr err)))))))))))))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 6c1ee70b205..fe4f7b8bb54 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1712,19 +1712,6 @@ letter into the file name. This function removes it."
1712 (replace-match "/" nil t name) 1712 (replace-match "/" nil t name)
1713 name))) 1713 name)))
1714 1714
1715(defun tramp-cleanup (vec)
1716 "Cleanup connection VEC, but keep the debug buffer."
1717 (with-current-buffer (tramp-get-debug-buffer vec)
1718 ;; Keep the debug buffer.
1719 (rename-buffer
1720 (generate-new-buffer-name tramp-temp-buffer-name) 'unique)
1721 (tramp-cleanup-connection vec)
1722 (if (= (point-min) (point-max))
1723 (kill-buffer nil)
1724 (rename-buffer (tramp-debug-buffer-name vec) 'unique))
1725 ;; We call `tramp-get-buffer' in order to keep the debug buffer.
1726 (tramp-get-buffer vec)))
1727
1728;;; Config Manipulation Functions: 1715;;; Config Manipulation Functions:
1729 1716
1730;;;###tramp-autoload 1717;;;###tramp-autoload
@@ -2147,7 +2134,7 @@ Falls back to normal file name handler if no Tramp file name handler exists."
2147 (tramp-message 2134 (tramp-message
2148 v 1 "Suppress received in operation %s" 2135 v 1 "Suppress received in operation %s"
2149 (append (list operation) args)) 2136 (append (list operation) args))
2150 (tramp-cleanup v) 2137 (tramp-cleanup-connection v t)
2151 (tramp-run-real-handler operation args))) 2138 (tramp-run-real-handler operation args)))
2152 (t result))) 2139 (t result)))
2153 2140