1251 |
'undecided-dos) |
'undecided-dos) |
1252 |
"Some Emacsen know the `dos' coding system, others need `undecided-dos'.") |
"Some Emacsen know the `dos' coding system, others need `undecided-dos'.") |
1253 |
|
|
1254 |
|
(defvar tramp-last-cmd-time nil |
1255 |
|
"Internal Tramp variable recording the time when the last cmd was sent. |
1256 |
|
This variable is buffer-local in every buffer.") |
1257 |
|
(make-variable-buffer-local 'tramp-last-cmd-time) |
1258 |
|
|
1259 |
;; New handlers should be added here. The following operations can be |
;; New handlers should be added here. The following operations can be |
1260 |
;; handled using the normal primitives: file-name-as-directory, |
;; handled using the normal primitives: file-name-as-directory, |
4464 |
"Maybe open a connection to HOST, logging in as USER, using METHOD. |
"Maybe open a connection to HOST, logging in as USER, using METHOD. |
4465 |
Does not do anything if a connection is already open, but re-opens the |
Does not do anything if a connection is already open, but re-opens the |
4466 |
connection if a previous connection has died for some reason." |
connection if a previous connection has died for some reason." |
4467 |
(let ((p (get-buffer-process (tramp-get-buffer multi-method method user host)))) |
(let ((p (get-buffer-process (tramp-get-buffer multi-method method user host))) |
4468 |
(unless (and p |
last-cmd-time) |
4469 |
(processp p) |
;; If too much time has passed since last command was sent, look |
4470 |
(memq (process-status p) '(run open))) |
;; whether process is still alive. If it isn't, kill it. When |
4471 |
|
;; using ssh, it can sometimes happen that the remote end has hung |
4472 |
|
;; up but the local ssh client doesn't recognize this until it |
4473 |
|
;; tries to send some data to the remote end. So that's why we |
4474 |
|
;; try to send a command from time to time, then look again |
4475 |
|
;; whether the process is really alive. |
4476 |
|
(save-excursion |
4477 |
|
(set-buffer (tramp-get-buffer multi-method method user host)) |
4478 |
|
(when (> (tramp-time-diff tramp-last-cmd-time (current-time)) 60) |
4479 |
|
(process-send-string p (concat "echo hello" tramp-rsh-end-of-line)) |
4480 |
|
(if (accept-process-output p 2) |
4481 |
|
(erase-buffer) |
4482 |
|
(delete-process p) |
4483 |
|
(setq p nil)))) |
4484 |
|
(unless (and p (processp p) (memq (process-status p) '(run open))) |
4485 |
(when (and p (processp p)) |
(when (and p (processp p)) |
4486 |
(delete-process p)) |
(delete-process p)) |
4487 |
(funcall (tramp-get-connection-function multi-method method) |
(funcall (tramp-get-connection-function multi-method method) |
4493 |
Erases temporary buffer before sending the command (unless NOERASE |
Erases temporary buffer before sending the command (unless NOERASE |
4494 |
is true)." |
is true)." |
4495 |
(tramp-maybe-open-connection multi-method method user host) |
(tramp-maybe-open-connection multi-method method user host) |
4496 |
|
(setq tramp-last-cmd-time (current-time)) |
4497 |
(when tramp-debug-buffer |
(when tramp-debug-buffer |
4498 |
(save-excursion |
(save-excursion |
4499 |
(set-buffer (tramp-get-debug-buffer multi-method method user host)) |
(set-buffer (tramp-get-debug-buffer multi-method method user host)) |