diff options
author | Christopher Baines <mail@cbaines.net> | 2020-05-24 09:24:54 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-05-24 09:24:54 +0100 |
commit | e153e06003853991ca1b2b50f194f848a8ffcbf9 (patch) | |
tree | cd12c03401520fb37743354bb624778df1b09fd1 | |
parent | 728e384197e581326d049ed609851877d59aa826 (diff) | |
download | build-coordinator-e153e06003853991ca1b2b50f194f848a8ffcbf9.tar build-coordinator-e153e06003853991ca1b2b50f194f848a8ffcbf9.tar.gz |
Guard against deq! erroring because the queue is empty
I'm not sure how this happens, but it seems to, so handle it.
-rw-r--r-- | guix-build-coordinator/utils.scm | 40 |
1 files 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)) |