guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/01: compile: Fix race condition on completion progress.


From: guix-commits
Subject: 01/01: compile: Fix race condition on completion progress.
Date: Fri, 27 Sep 2019 23:59:57 -0400 (EDT)

bavier pushed a commit to branch master
in repository guix.

commit 21391f8c83658797c9bfbc3ef8a552859e9d861d
Author: Eric Bavier <address@hidden>
Date:   Tue Sep 24 20:57:34 2019 -0500

    compile: Fix race condition on completion progress.
    
    This prevent a race condition where multiple compilation threads could 
report
    the same progress.
    
    * guix/build/compile.scm (compile-files)<completed>: Rename to...
    <progress>: ...this.  Increment in same mutex region as the compilation is
    reported.
---
 guix/build/compile.scm | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/guix/build/compile.scm b/guix/build/compile.scm
index c127456..06ed57c 100644
--- a/guix/build/compile.scm
+++ b/guix/build/compile.scm
@@ -169,11 +169,12 @@ BUILD-DIRECTORY, using up to WORKERS parallel workers.  
The resulting object
 files are for HOST, a GNU triplet such as \"x86_64-linux-gnu\"."
   (define progress-lock (make-mutex))
   (define total (length files))
-  (define completed 0)
+  (define progress 0)
 
   (define (build file)
     (with-mutex progress-lock
-      (report-compilation file total completed))
+      (report-compilation file total progress)
+      (set! progress (+ 1 progress)))
 
     ;; Exit as soon as something goes wrong.
     (exit-on-exception
@@ -185,9 +186,7 @@ files are for HOST, a GNU triplet such as 
\"x86_64-linux-gnu\"."
                          #:output-file (string-append build-directory "/"
                                                       (scm->go relative))
                          #:opts (append warning-options
-                                        (optimization-options relative)))))))
-    (with-mutex progress-lock
-      (set! completed (+ 1 completed))))
+                                        (optimization-options relative))))))))
 
   (with-augmented-search-path %load-path source-directory
     (with-augmented-search-path %load-compiled-path build-directory



reply via email to

[Prev in Thread] Current Thread [Next in Thread]