aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMichael Albinus2013-07-11 11:52:54 +0200
committerMichael Albinus2013-07-11 11:52:54 +0200
commit88f6a933892e3e2830325266ae5dfa4bcef06d12 (patch)
tree3a56ff63b4bbc7f34cd2b4bcab0ef4e0fce32105 /lisp
parent9c203066b952a8cd446464b384d2bec9be9355c5 (diff)
downloademacs-88f6a933892e3e2830325266ae5dfa4bcef06d12.tar.gz
emacs-88f6a933892e3e2830325266ae5dfa4bcef06d12.zip
* net/tramp.el (tramp-methods): Extend docstring.
(tramp-connection-timeout): New defcustom. (tramp-error-with-buffer): Reset timestamp only when appropriate. (with-tramp-progress-reporter): Simplify. (tramp-process-actions): Improve messages. * net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection): * net/tramp-sh.el (tramp-maybe-open-connection): Use `tramp-connection-timeout'. (tramp-methods) [su, sudo, ksu]: Add method specific timeouts. (Bug#14808)
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog14
-rw-r--r--lisp/net/tramp-gvfs.el3
-rw-r--r--lisp/net/tramp-sh.el17
-rw-r--r--lisp/net/tramp.el89
4 files changed, 79 insertions, 44 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4b9cbe829f3..29f053c5ae1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
12013-07-11 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp.el (tramp-methods): Extend docstring.
4 (tramp-connection-timeout): New defcustom.
5 (tramp-error-with-buffer): Reset timestamp only when appropriate.
6 (with-tramp-progress-reporter): Simplify.
7 (tramp-process-actions): Improve messages.
8
9 * net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection):
10 * net/tramp-sh.el (tramp-maybe-open-connection):
11 Use `tramp-connection-timeout'.
12 (tramp-methods) [su, sudo, ksu]: Add method specific timeouts.
13 (Bug#14808)
14
12013-07-11 Leo Liu <sdl.web@gmail.com> 152013-07-11 Leo Liu <sdl.web@gmail.com>
2 16
3 * ido.el (ido-read-file-name): Conform to the requirements of 17 * ido.el (ido-read-file-name): Conform to the requirements of
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 6ba055b8bb8..c2fdc0491b6 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1539,7 +1539,8 @@ connection if a previous connection has died for some reason."
1539 ;; indicated by the "mounted" signal, i.e. the "fuse-mountpoint" 1539 ;; indicated by the "mounted" signal, i.e. the "fuse-mountpoint"
1540 ;; file property. 1540 ;; file property.
1541 (with-timeout 1541 (with-timeout
1542 (60 1542 ((or (tramp-get-method-parameter method 'tramp-connection-timeout)
1543 tramp-connection-timeout)
1543 (if (zerop (length (tramp-file-name-user vec))) 1544 (if (zerop (length (tramp-file-name-user vec)))
1544 (tramp-error 1545 (tramp-error
1545 vec 'file-error 1546 vec 'file-error
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index baa76026bba..281f497692d 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -222,21 +222,24 @@ detected as prompt when being sent on echoing hosts, therefore.")
222 (tramp-login-program "su") 222 (tramp-login-program "su")
223 (tramp-login-args (("-") ("%u"))) 223 (tramp-login-args (("-") ("%u")))
224 (tramp-remote-shell "/bin/sh") 224 (tramp-remote-shell "/bin/sh")
225 (tramp-remote-shell-args ("-c")))) 225 (tramp-remote-shell-args ("-c"))
226 (tramp-connection-timeout 10)))
226;;;###tramp-autoload 227;;;###tramp-autoload
227(add-to-list 'tramp-methods 228(add-to-list 'tramp-methods
228 '("sudo" 229 '("sudo"
229 (tramp-login-program "sudo") 230 (tramp-login-program "sudo")
230 (tramp-login-args (("-u" "%u") ("-s") ("-H") ("-p" "Password:"))) 231 (tramp-login-args (("-u" "%u") ("-s") ("-H") ("-p" "Password:")))
231 (tramp-remote-shell "/bin/sh") 232 (tramp-remote-shell "/bin/sh")
232 (tramp-remote-shell-args ("-c")))) 233 (tramp-remote-shell-args ("-c"))
234 (tramp-connection-timeout 10)))
233;;;###tramp-autoload 235;;;###tramp-autoload
234(add-to-list 'tramp-methods 236(add-to-list 'tramp-methods
235 '("ksu" 237 '("ksu"
236 (tramp-login-program "ksu") 238 (tramp-login-program "ksu")
237 (tramp-login-args (("%u") ("-q"))) 239 (tramp-login-args (("%u") ("-q")))
238 (tramp-remote-shell "/bin/sh") 240 (tramp-remote-shell "/bin/sh")
239 (tramp-remote-shell-args ("-c")))) 241 (tramp-remote-shell-args ("-c"))
242 (tramp-connection-timeout 10)))
240;;;###tramp-autoload 243;;;###tramp-autoload
241(add-to-list 'tramp-methods 244(add-to-list 'tramp-methods
242 '("krlogin" 245 '("krlogin"
@@ -4442,7 +4445,7 @@ connection if a previous connection has died for some reason."
4442 4445
4443 ;; Check whether process is alive. 4446 ;; Check whether process is alive.
4444 (tramp-barf-if-no-shell-prompt 4447 (tramp-barf-if-no-shell-prompt
4445 p 60 4448 p 10
4446 "Couldn't find local shell prompt for %s" tramp-encoding-shell) 4449 "Couldn't find local shell prompt for %s" tramp-encoding-shell)
4447 4450
4448 ;; Now do all the connections as specified. 4451 ;; Now do all the connections as specified.
@@ -4461,6 +4464,9 @@ connection if a previous connection has died for some reason."
4461 (async-args 4464 (async-args
4462 (tramp-get-method-parameter 4465 (tramp-get-method-parameter
4463 l-method 'tramp-async-args)) 4466 l-method 'tramp-async-args))
4467 (connection-timeout
4468 (tramp-get-method-parameter
4469 l-method 'tramp-connection-timeout))
4464 (gw-args 4470 (gw-args
4465 (tramp-get-method-parameter l-method 'tramp-gw-args)) 4471 (tramp-get-method-parameter l-method 'tramp-gw-args))
4466 (gw (tramp-get-file-property hop "" "gateway" nil)) 4472 (gw (tramp-get-file-property hop "" "gateway" nil))
@@ -4543,7 +4549,8 @@ connection if a previous connection has died for some reason."
4543 (tramp-message vec 3 "Sending command `%s'" command) 4549 (tramp-message vec 3 "Sending command `%s'" command)
4544 (tramp-send-command vec command t t) 4550 (tramp-send-command vec command t t)
4545 (tramp-process-actions 4551 (tramp-process-actions
4546 p vec pos tramp-actions-before-shell 60) 4552 p vec pos tramp-actions-before-shell
4553 (or connection-timeout tramp-connection-timeout))
4547 (tramp-message 4554 (tramp-message
4548 vec 3 "Found remote shell prompt on `%s'" l-host)) 4555 vec 3 "Found remote shell prompt on `%s'" l-host))
4549 ;; Next hop. 4556 ;; Next hop.
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 6c5fd5e5dd4..3513701d20e 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -252,6 +252,11 @@ pair of the form (KEY VALUE). The following KEYs are defined:
252 * `tramp-tmpdir' 252 * `tramp-tmpdir'
253 A directory on the remote host for temporary files. If not 253 A directory on the remote host for temporary files. If not
254 specified, \"/tmp\" is taken as default. 254 specified, \"/tmp\" is taken as default.
255 * `tramp-connection-timeout'
256 This is the maximum time to be spent for establishing a connection.
257 In general, the global default value shall be used, but for
258 some methods, like \"su\" or \"sudo\", a shorter timeout
259 might be desirable.
255 260
256What does all this mean? Well, you should specify `tramp-login-program' 261What does all this mean? Well, you should specify `tramp-login-program'
257for all methods; this program is used to log in to the remote site. Then, 262for all methods; this program is used to log in to the remote site. Then,
@@ -1034,6 +1039,13 @@ opening a connection to a remote host."
1034 :group 'tramp 1039 :group 'tramp
1035 :type '(choice (const nil) (const t) (const pty))) 1040 :type '(choice (const nil) (const t) (const pty)))
1036 1041
1042(defcustom tramp-connection-timeout 60
1043 "Defines the max time to wait for establishing a connection (in seconds).
1044This can be overwritten for different connection types in `tramp-methods'."
1045 :group 'tramp
1046 :version "24.4"
1047 :type 'integer)
1048
1037(defcustom tramp-connection-min-time-diff 5 1049(defcustom tramp-connection-min-time-diff 5
1038 "Defines seconds between two consecutive connection attempts. 1050 "Defines seconds between two consecutive connection attempts.
1039This is necessary as self defense mechanism, in order to avoid 1051This is necessary as self defense mechanism, in order to avoid
@@ -1535,24 +1547,32 @@ signal identifier to be raised, remaining args passed to
1535If BUFFER is nil, show the connection buffer. Wait for 30\", or until 1547If BUFFER is nil, show the connection buffer. Wait for 30\", or until
1536an input event arrives. The other arguments are passed to `tramp-error'." 1548an input event arrives. The other arguments are passed to `tramp-error'."
1537 (save-window-excursion 1549 (save-window-excursion
1538 (unwind-protect 1550 (let* ((buf (or (and (bufferp buffer) buffer)
1539 (apply 'tramp-error vec-or-proc signal fmt-string args) 1551 (and (processp vec-or-proc) (process-buffer vec-or-proc))
1540 (when (and vec-or-proc 1552 (and (vectorp vec-or-proc)
1541 tramp-message-show-message 1553 (tramp-get-connection-buffer vec-or-proc))))
1542 (not (zerop tramp-verbose)) 1554 (vec (or (and (vectorp vec-or-proc) vec-or-proc)
1543 (not (tramp-completion-mode-p))) 1555 (and buf (with-current-buffer buf
1544 (let ((enable-recursive-minibuffers t)) 1556 (tramp-dissect-file-name default-directory))))))
1545 (pop-to-buffer 1557 (unwind-protect
1546 (or (and (bufferp buffer) buffer) 1558 (apply 'tramp-error vec-or-proc signal fmt-string args)
1547 (and (processp vec-or-proc) (process-buffer vec-or-proc)) 1559 ;; Save exit.
1548 (tramp-get-connection-buffer vec-or-proc))) 1560 (when (and buf
1549 ;; `tramp-error' does not show messages. So we must do it ourselves. 1561 tramp-message-show-message
1550 (message fmt-string args) 1562 (not (zerop tramp-verbose))
1551 (discard-input) 1563 (not (tramp-completion-mode-p)))
1552 (sit-for 30))) 1564 (let ((enable-recursive-minibuffers t))
1553 ;; Reset timestamp. It would be wrong after waiting for a while. 1565 ;; `tramp-error' does not show messages. So we must do it
1554 (when tramp-current-connection 1566 ;; ourselves.
1555 (setcdr tramp-current-connection (current-time)))))) 1567 (message fmt-string args)
1568 ;; Show buffer.
1569 (pop-to-buffer buf)
1570 (discard-input)
1571 (sit-for 30)))
1572 ;; Reset timestamp. It would be wrong after waiting for a while.
1573 (when (equal (butlast (append vec nil) 2)
1574 (car tramp-current-connection))
1575 (setcdr tramp-current-connection (current-time)))))))
1556 1576
1557(defmacro with-parsed-tramp-file-name (filename var &rest body) 1577(defmacro with-parsed-tramp-file-name (filename var &rest body)
1558 "Parse a Tramp filename and make components available in the body. 1578 "Parse a Tramp filename and make components available in the body.
@@ -1596,11 +1616,11 @@ If VAR is nil, then we bind `v' to the structure and `method', `user',
1596 1616
1597(defmacro with-tramp-progress-reporter (vec level message &rest body) 1617(defmacro with-tramp-progress-reporter (vec level message &rest body)
1598 "Executes BODY, spinning a progress reporter with MESSAGE. 1618 "Executes BODY, spinning a progress reporter with MESSAGE.
1599If LEVEL does not fit for visible messages, or if this is a 1619If LEVEL does not fit for visible messages, there are only traces
1600nested call of the macro, there are only traces without a visible 1620without a visible progress reporter."
1601progress reporter."
1602 (declare (indent 3) (debug t)) 1621 (declare (indent 3) (debug t))
1603 `(let (pr tm result) 1622 `(let ((result "failed")
1623 pr tm)
1604 (tramp-message ,vec ,level "%s..." ,message) 1624 (tramp-message ,vec ,level "%s..." ,message)
1605 ;; We start a pulsing progress reporter after 3 seconds. Feature 1625 ;; We start a pulsing progress reporter after 3 seconds. Feature
1606 ;; introduced in Emacs 24.1. 1626 ;; introduced in Emacs 24.1.
@@ -1611,21 +1631,12 @@ progress reporter."
1611 (setq pr (tramp-compat-funcall 'make-progress-reporter ,message) 1631 (setq pr (tramp-compat-funcall 'make-progress-reporter ,message)
1612 tm (when pr 1632 tm (when pr
1613 (run-at-time 3 0.1 'tramp-progress-reporter-update pr))))) 1633 (run-at-time 3 0.1 'tramp-progress-reporter-update pr)))))
1614 (condition-case err 1634 (unwind-protect
1615 (unwind-protect 1635 ;; Execute the body.
1616 ;; Execute the body. 1636 (prog1 (progn ,@body) (setq result "done"))
1617 (setq result (progn ,@body)) 1637 ;; Stop progress reporter.
1618 ;; Stop progress reporter. 1638 (if tm (tramp-compat-funcall 'cancel-timer tm))
1619 (if tm (tramp-compat-funcall 'cancel-timer tm))) 1639 (tramp-message ,vec ,level "%s...%s" ,message result))))
1620
1621 ;; Error handling.
1622 ((error quit)
1623 (tramp-message ,vec ,level "%s...failed" ,message)
1624 (signal (car err) (cdr err))))
1625
1626 ;; Exit.
1627 (tramp-message ,vec ,level "%s...done" ,message)
1628 result))
1629 1640
1630(tramp-compat-font-lock-add-keywords 1641(tramp-compat-font-lock-add-keywords
1631 'emacs-lisp-mode '("\\<with-tramp-progress-reporter\\>")) 1642 'emacs-lisp-mode '("\\<with-tramp-progress-reporter\\>"))
@@ -3434,7 +3445,9 @@ connection buffer."
3434 "Tramp failed to connect. If this happens repeatedly, try\n" 3445 "Tramp failed to connect. If this happens repeatedly, try\n"
3435 " `M-x tramp-cleanup-this-connection'")) 3446 " `M-x tramp-cleanup-this-connection'"))
3436 ((eq exit 'timeout) 3447 ((eq exit 'timeout)
3437 "Timeout reached. Check the buffer for the error reason") 3448 (format
3449 "Timeout reached, see buffer `%s' for details"
3450 (tramp-get-connection-buffer vec)))
3438 (t "Login failed"))))) 3451 (t "Login failed")))))
3439 (when (numberp pos) 3452 (when (numberp pos)
3440 (with-current-buffer (tramp-get-connection-buffer vec) 3453 (with-current-buffer (tramp-get-connection-buffer vec)