aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-01-23 23:45:24 +0100
committerLudovic Courtès <ludo@gnu.org>2018-01-23 23:45:24 +0100
commitd544f3e6baa42ec890baec268f207902c5cc0faf (patch)
tree5a7a59de45bb138b9a63ba36e7e93d83ec51435a
parentc1edfe8895060f88855236c6faee9e085e72ca6f (diff)
downloadcuirass-d544f3e6baa42ec890baec268f207902c5cc0faf.tar
cuirass-d544f3e6baa42ec890baec268f207902c5cc0faf.tar.gz
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.
-rw-r--r--bin/cuirass.in6
-rw-r--r--src/cuirass/base.scm47
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:-@GUILE@} --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:-@GUILE@} --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."