]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid race condition in parallel native-compilation
authorAaron Jensen <aaronjensen@gmail.com>
Sat, 30 Dec 2023 23:06:45 +0000 (18:06 -0500)
committerEshel Yaron <me@eshelyaron.com>
Tue, 2 Jan 2024 07:59:40 +0000 (08:59 +0100)
* lisp/emacs-lisp/comp.el (comp-delete-or-replace-file): Avoid
race condition by relying on 'rename-file' being an atomic
operation on Posix filesystems.  (Bug#68083)

(cherry picked from commit 6e2e34a5caa75a3430a1fb0d89900f9911c50436)

lisp/emacs-lisp/comp.el

index 3b2fd25e61c04f1adccb2683fd94010ec500a0af..f9eeef1b9e8310c64018bc4034cd865b5dada609 100644 (file)
@@ -3339,9 +3339,9 @@ session."
         ;; Remove the old eln instead of copying the new one into it
         ;; to get a new inode and prevent crashes in case the old one
         ;; is currently loaded.
-        (t (delete-file oldfile)
-           (when newfile
-             (rename-file newfile oldfile)))))
+        (t (if newfile
+               (rename-file newfile oldfile t)
+             (delete-file oldfile)))))
 
 (defun comp--native-compile (function-or-file &optional with-late-load output)
   "Compile FUNCTION-OR-FILE into native code.