guix-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Ludovic Courtès
Date: Tue, 23 Jan 2018 17:46:44 -0500 (EST)

branch: master
commit d544f3e6baa42ec890baec268f207902c5cc0faf
Author: Ludovic Courtès <address@hidden>
Date:   Tue Jan 23 23:45:24 2018 +0100

    cuirass: Fix scope mismatch.
    
    Previously STORE would be closed on the first context switch, before
    'restart-builds' has completed, leading to an error (writing to a closed
    port).
    
    * src/cuirass/base.scm (restart-builds): Remove 'store' parameter.  Wrap
    body in 'with-store'.
    * bin/cuirass.in (main): Adjust accordingly.
---
 bin/cuirass.in       |  6 ++----
 src/cuirass/base.scm | 47 ++++++++++++++++++++++++-----------------------
 2 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/bin/cuirass.in b/bin/cuirass.in
index d2cb897..9ece178 100644
--- a/bin/cuirass.in
+++ b/bin/cuirass.in
@@ -28,7 +28,6 @@ exec ${GUILE:address@hidden@} --no-auto-compile -e main -s 
"$0" "$@"
              (cuirass ui)
              (cuirass logging)
              (guix ui)
-             (guix store)
              (fibers)
              (ice-9 getopt-long))
 
@@ -113,9 +112,8 @@ exec ${GUILE:address@hidden@} --no-auto-compile -e main -s 
"$0" "$@"
                      ;; were not even started on a previous run.
                      (spawn-fiber
                       (lambda ()
-                        (with-store store
-                          (with-database db
-                            (restart-builds store db pending)))))
+                        (with-database db
+                          (restart-builds db pending))))
 
                      (spawn-fiber
                       (lambda ()
diff --git a/src/cuirass/base.scm b/src/cuirass/base.scm
index 295c64b..360b6e6 100644
--- a/src/cuirass/base.scm
+++ b/src/cuirass/base.scm
@@ -293,30 +293,31 @@ updating DB accordingly."
     (_
      (log-message "build event: ~s" event))))
 
-(define (restart-builds store db builds)
+(define (restart-builds db builds)
   "Restart builds whose status in DB is \"pending\" (scheduled or started)."
-  (let-values (((valid stale)
-                (partition (lambda (build)
-                             (let ((drv (assq-ref build #:derivation)))
-                               (valid-path? store drv)))
-                           builds)))
-    ;; We cannot restart builds listed in STALE, so mark them as canceled.
-    (log-message "canceling ~a pending builds" (length stale))
-    (for-each (lambda (build)
-                (db-update-build-status! db (assq-ref build #:derivation)
-                                         (build-status canceled)))
-              stale)
-
-    ;; Those in VALID can be restarted.
-    (log-message "restarting ~a pending builds" (length valid))
-    (parameterize ((current-build-output-port
-                    (build-event-output-port (lambda (event status)
-                                               (handle-build-event db event))
-                                             #t)))
-      (build-derivations store
-                         (map (lambda (build)
-                                (assq-ref build #:derivation))
-                              valid)))))
+  (with-store store
+    (let-values (((valid stale)
+                  (partition (lambda (build)
+                               (let ((drv (assq-ref build #:derivation)))
+                                 (valid-path? store drv)))
+                             builds)))
+      ;; We cannot restart builds listed in STALE, so mark them as canceled.
+      (log-message "canceling ~a pending builds" (length stale))
+      (for-each (lambda (build)
+                  (db-update-build-status! db (assq-ref build #:derivation)
+                                           (build-status canceled)))
+                stale)
+
+      ;; Those in VALID can be restarted.
+      (log-message "restarting ~a pending builds" (length valid))
+      (parameterize ((current-build-output-port
+                      (build-event-output-port (lambda (event status)
+                                                 (handle-build-event db event))
+                                               #t)))
+        (build-derivations store
+                           (map (lambda (build)
+                                  (assq-ref build #:derivation))
+                                valid))))))
 
 (define (build-packages store db jobs)
   "Build JOBS and return a list of Build results."



reply via email to

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