]> git.eshelyaron.com Git - emacs.git/commitdiff
Merge branch 'master' into feature/tramp-thread-safe
authorMichael Albinus <michael.albinus@gmx.de>
Fri, 17 Aug 2018 08:33:10 +0000 (10:33 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Fri, 17 Aug 2018 08:33:10 +0000 (10:33 +0200)
1  2 
doc/emacs/files.texi
doc/misc/tramp.texi
etc/NEWS
lisp/files.el
lisp/simple.el
lisp/vc/vc-hooks.el
test/lisp/net/tramp-tests.el

Simple merge
Simple merge
diff --cc etc/NEWS
Simple merge
diff --cc lisp/files.el
index 4054934b1dbbf2b6810eb4112039a47db08177a1,da4f2cd78feca804884d289483a0432a86c90333..d5dab88f27792f9beba27a72bcffd6e2da3de55c
@@@ -1893,9 -1830,8 +1893,9 @@@ killed.
            ;; Don't use `find-file' because it may end up using another window
            ;; in some corner cases, e.g. when the selected window is
            ;; softly-dedicated.
 -        (let ((newbuf (find-file-noselect filename nil nil wildcards)))
 +        (let ((newbuf
 +                 (find-file-noselect filename nil nil wildcards async)))
-             (switch-to-buffer newbuf)))
+             (switch-to-buffer (if (consp newbuf) (car newbuf) newbuf))))
        (when (eq obuf (current-buffer))
        ;; This executes if find-file gets an error
        ;; and does not really find anything.
diff --cc lisp/simple.el
Simple merge
Simple merge
index 29a8df8975bbe32f1779d98fd7538b2f8443692b,293a0054560db74d23dd9b2e994c1372b2857557..e1838d152ced613b67d8f2b643117cfacbff68db
@@@ -5053,108 -5053,11 +5053,110 @@@ process sentinels.  They shall not dist
          (ignore-errors (cancel-timer timer))
          (ignore-errors (delete-directory tmp-name 'recursive)))))))
  
 +(ert-deftest tramp-test43-threads ()
 +  "Check that Tramp cooperates with threads."
 +  (skip-unless (tramp--test-enabled))
 +  (skip-unless (featurep 'threads))
 +  (skip-unless (= (length (all-threads)) 1))
 +  (skip-unless (not (thread-last-error)))
 +
 +  ;; We cannot bind the variables dynamically; they are used in the threads.
 +  (defvar tmp-name1 (tramp--test-make-temp-name))
 +  (defvar tmp-name2 (tramp--test-make-temp-name))
 +  (defvar tmp-mutex (make-mutex "mutex"))
 +  (defvar tmp-condvar1 (make-condition-variable tmp-mutex "condvar1"))
 +  (defvar tmp-condvar2 (make-condition-variable tmp-mutex "condvar2"))
 +
 +  ;; Rename simple file.
 +  (unwind-protect
 +      (let (tmp-thread1 tmp-thread2)
 +      (write-region "foo" nil tmp-name1)
 +      (should (file-exists-p tmp-name1))
 +      (should-not (file-exists-p tmp-name2))
 +
 +      (should (mutexp tmp-mutex))
 +      (should (condition-variable-p tmp-condvar1))
 +      (should (condition-variable-p tmp-condvar2))
 +
 +      ;; This thread renames `tmp-name1' to `tmp-name2' twice.
 +      (setq
 +       tmp-thread1
 +       (make-thread
 +        (lambda ()
 +          ;; Rename first time.
 +          (rename-file tmp-name1 tmp-name2)
 +          ;; Notify thread2.
 +          (with-mutex (condition-mutex tmp-condvar2)
 +            (condition-notify tmp-condvar2 t))
 +          ;; Rename second time, once we've got notification from thread2.
 +          (with-mutex (condition-mutex tmp-condvar1)
 +            (condition-wait tmp-condvar1))
 +          (rename-file tmp-name1 tmp-name2))
 +        "thread1"))
 +
 +      (should (threadp tmp-thread1))
 +      (should (thread-alive-p tmp-thread1))
 +
 +      ;; This thread renames `tmp-name2' to `tmp-name1' twice.
 +      (setq
 +       tmp-thread2
 +       (make-thread
 +        (lambda ()
 +          ;; Rename first time, once we've got notification from thread1.
 +          (with-mutex (condition-mutex tmp-condvar2)
 +            (condition-wait tmp-condvar2))
 +          (rename-file tmp-name2 tmp-name1)
 +          ;; Notify thread1.
 +          (with-mutex (condition-mutex tmp-condvar1)
 +            (condition-notify tmp-condvar1 t))
 +          ;; Rename second time, once we've got notification from
 +          ;; the main thread.
 +          (with-mutex (condition-mutex tmp-condvar2)
 +            (condition-wait tmp-condvar2))
 +          (rename-file tmp-name2 tmp-name1))
 +        "thread2"))
 +
 +      (should (threadp tmp-thread2))
 +      (should (thread-alive-p tmp-thread2))
 +      (should (= (length (all-threads)) 3))
 +
 +      ;; Wait for thread1.
 +      (thread-join tmp-thread1)
 +      ;; Checks.
 +      (should-not (thread-alive-p tmp-thread1))
 +      (should (= (length (all-threads)) 2))
 +      (should-not (thread-last-error))
 +      (should (file-exists-p tmp-name2))
 +      (should-not (file-exists-p tmp-name1))
 +
 +      ;; Notify thread2.
 +      (with-mutex (condition-mutex tmp-condvar2)
 +        (condition-notify tmp-condvar2 t))
 +
 +      ;; Wait for thread2.
 +      (thread-join tmp-thread2)
 +      ;; Checks.
 +      (should-not (thread-alive-p tmp-thread2))
 +      (should (= (length (all-threads)) 1))
 +      (should-not (thread-last-error))
 +      (should (file-exists-p tmp-name1))
 +      (should-not (file-exists-p tmp-name2)))
 +
 +    ;; Cleanup.
 +    (ignore-errors (delete-file tmp-name1))
 +    (ignore-errors (delete-file tmp-name2))
 +    ;; We could have spurious threads still running; wait for them to die.
 +    (while (cdr (all-threads))
 +      (thread-signal (cadr (all-threads)) 'error nil)
 +      (thread-yield))
 +    ;; Cleanup errors.
 +    (thread-last-error 'cleanup)))
 +
  ;; This test is inspired by Bug#29163.
 -(ert-deftest tramp-test43-auto-load ()
 +(ert-deftest tramp-test44-auto-load ()
    "Check that Tramp autoloads properly."
+   (skip-unless (tramp--test-enabled))
    (let ((default-directory (expand-file-name temporary-file-directory))
        (code
         (format