summaryrefslogtreecommitdiff
path: root/lisp/net
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2017-02-01 10:06:37 +0100
committerMichael Albinus <michael.albinus@gmx.de>2017-02-01 10:06:37 +0100
commitd805757618092d5d46b8a95d2a046146c4916dc6 (patch)
treeb3dbba8f933f7e5a4bd9566c8188a6164d1a4bbe /lisp/net
parent12da2a5beafc4595fe4dd922431ba9f013b84830 (diff)
downloademacs-d805757618092d5d46b8a95d2a046146c4916dc6.tar.gz
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>.
Diffstat (limited to 'lisp/net')
-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."
;;; Utility functions:
-(defun tramp-accept-process-output (&optional proc timeout timeout-msecs)
+(defun tramp-accept-process-output (proc timeout)
"Like `accept-process-output' for Tramp processes.
This is needed in order to hide `last-coding-system-used', which is set
for process communication also."
+ ;; FIXME: There are problems, when an asynchronous process runs in
+ ;; parallel, and also timers are active. See
+ ;; <http://lists.gnu.org/archive/html/tramp-devel/2017-01/msg00010.html>.
+ (when (and timer-event-last
+ (string-prefix-p "*tramp/" (process-name proc))
+ (let (result)
+ (maphash
+ (lambda (key _value)
+ (and (processp key)
+ (not (string-prefix-p "*tramp/" (process-name key)))
+ (tramp-compat-process-live-p key)
+ (setq result t)))
+ tramp-cache-data)
+ result))
+ (sit-for 0.01 'nodisp))
(with-current-buffer (process-buffer proc)
(let (buffer-read-only last-coding-system-used)
;; Under Windows XP, accept-process-output doesn't return
- ;; sometimes. So we add an additional timeout.
- (with-timeout ((or timeout 1))
- (accept-process-output proc timeout timeout-msecs (and proc t)))
- (tramp-message proc 10 "%s %s\n%s"
- proc (process-status proc) (buffer-string)))))
+ ;; sometimes. So we add an additional timeout. JUST-THIS-ONE
+ ;; is set due to Bug#12145.
+ (tramp-message
+ proc 10 "%s %s %s\n%s"
+ proc (process-status proc)
+ (with-timeout (timeout)
+ (accept-process-output proc timeout nil t))
+ (buffer-string)))))
(defun tramp-check-for-regexp (proc regexp)
"Check, whether REGEXP is contained in process buffer of PROC.