aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2017-02-01 10:06:37 +0100
committerMichael Albinus2017-02-01 10:06:37 +0100
commitd805757618092d5d46b8a95d2a046146c4916dc6 (patch)
treeb3dbba8f933f7e5a4bd9566c8188a6164d1a4bbe
parent12da2a5beafc4595fe4dd922431ba9f013b84830 (diff)
downloademacs-d805757618092d5d46b8a95d2a046146c4916dc6.tar.gz
emacs-d805757618092d5d46b8a95d2a046146c4916dc6.zip
Fix a subtle problem in Tramp with timers
* lisp/net/tramp.el (tramp-accept-process-output): Change argument list. Make it work when called inside a timer. See <http://lists.gnu.org/archive/html/tramp-devel/2017-01/msg00010.html>.
-rw-r--r--lisp/net/tramp.el30
1 files changed, 24 insertions, 6 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index fc7fdd30850..48dcd5edd11 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3614,18 +3614,36 @@ connection buffer."
3614 3614
3615;;; Utility functions: 3615;;; Utility functions:
3616 3616
3617(defun tramp-accept-process-output (&optional proc timeout timeout-msecs) 3617(defun tramp-accept-process-output (proc timeout)
3618 "Like `accept-process-output' for Tramp processes. 3618 "Like `accept-process-output' for Tramp processes.
3619This is needed in order to hide `last-coding-system-used', which is set 3619This is needed in order to hide `last-coding-system-used', which is set
3620for process communication also." 3620for process communication also."
3621 ;; FIXME: There are problems, when an asynchronous process runs in
3622 ;; parallel, and also timers are active. See
3623 ;; <http://lists.gnu.org/archive/html/tramp-devel/2017-01/msg00010.html>.
3624 (when (and timer-event-last
3625 (string-prefix-p "*tramp/" (process-name proc))
3626 (let (result)
3627 (maphash
3628 (lambda (key _value)
3629 (and (processp key)
3630 (not (string-prefix-p "*tramp/" (process-name key)))
3631 (tramp-compat-process-live-p key)
3632 (setq result t)))
3633 tramp-cache-data)
3634 result))
3635 (sit-for 0.01 'nodisp))
3621 (with-current-buffer (process-buffer proc) 3636 (with-current-buffer (process-buffer proc)
3622 (let (buffer-read-only last-coding-system-used) 3637 (let (buffer-read-only last-coding-system-used)
3623 ;; Under Windows XP, accept-process-output doesn't return 3638 ;; Under Windows XP, accept-process-output doesn't return
3624 ;; sometimes. So we add an additional timeout. 3639 ;; sometimes. So we add an additional timeout. JUST-THIS-ONE
3625 (with-timeout ((or timeout 1)) 3640 ;; is set due to Bug#12145.
3626 (accept-process-output proc timeout timeout-msecs (and proc t))) 3641 (tramp-message
3627 (tramp-message proc 10 "%s %s\n%s" 3642 proc 10 "%s %s %s\n%s"
3628 proc (process-status proc) (buffer-string))))) 3643 proc (process-status proc)
3644 (with-timeout (timeout)
3645 (accept-process-output proc timeout nil t))
3646 (buffer-string)))))
3629 3647
3630(defun tramp-check-for-regexp (proc regexp) 3648(defun tramp-check-for-regexp (proc regexp)
3631 "Check, whether REGEXP is contained in process buffer of PROC. 3649 "Check, whether REGEXP is contained in process buffer of PROC.