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.
This commit is contained in:
Ludovic Courtès 2018-01-23 23:45:24 +01:00
parent c1edfe8895
commit d544f3e6ba
2 changed files with 25 additions and 26 deletions

View File

@ -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 ()

View File

@ -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)
(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)))))
;; 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."