From e153e06003853991ca1b2b50f194f848a8ffcbf9 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sun, 24 May 2020 09:24:54 +0100 Subject: Guard against deq! erroring because the queue is empty I'm not sure how this happens, but it seems to, so handle it. --- guix-build-coordinator/utils.scm | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm index 27f1988..239fe9f 100644 --- a/guix-build-coordinator/utils.scm +++ b/guix-build-coordinator/utils.scm @@ -552,21 +552,31 @@ References: ~a~%" (when (q-empty? queue) (wait-condition-variable job-available queue-mutex)) - (let ((job-args (deq! queue))) - (set! running-jobs-count (+ 1 running-jobs-count)) - (unlock-mutex queue-mutex) - (with-exception-handler - (lambda (exn) - (simple-format (current-error-port) - "exception when handling job: ~A\n" - exn) - ;; Add the job back to the queue so that it's tried again - (apply process-job job-args)) - (lambda () - (apply proc job-args)) - #:unwind? #t) - (with-mutex queue-mutex - (set! running-jobs-count (- running-jobs-count 1)))) + (and=> + (with-exception-handler + (lambda (exn) + (simple-format (current-error-port) + "exception for deq!: ~A\n" + exn) + #f) + (lambda () + (deq! queue)) + #:unwind? #t) + (lambda (job-args) + (set! running-jobs-count (+ 1 running-jobs-count)) + (unlock-mutex queue-mutex) + (with-exception-handler + (lambda (exn) + (simple-format (current-error-port) + "exception when handling job: ~A\n" + exn) + ;; Add the job back to the queue so that it's tried again + (apply process-job job-args)) + (lambda () + (apply proc job-args)) + #:unwind? #t) + (with-mutex queue-mutex + (set! running-jobs-count (- running-jobs-count 1))))) (loop))))) (iota thread-count)) -- cgit v1.2.3