From 65bbc4d8629be2d74a3399e6911010f614527af5 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 6 Dec 2023 17:59:29 +0000 Subject: Guard against exceptions in the thread pool --- guix-build-coordinator/utils.scm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'guix-build-coordinator/utils.scm') diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm index 7fe0470..e07ed9b 100644 --- a/guix-build-coordinator/utils.scm +++ b/guix-build-coordinator/utils.scm @@ -1066,7 +1066,20 @@ References: ~a~%" ((number? thread-count-parameter) (const thread-count-parameter)) (else - thread-count-parameter))) + (lambda () + (with-exception-handler + (lambda (exn) + (count-threads)) + thread-count-parameter + #:unwind? #t))))) + + (define (get-job/safe running-jobs) + (with-exception-handler + (lambda (exn) + #f) + (lambda () + (get-job running-jobs)) + #:unwind? #t)) (define (count-threads) (hash-count (const #t) running-job-args)) @@ -1137,12 +1150,12 @@ References: ~a~%" #f) (let ((job-args - (or (get-job (list-jobs)) + (or (get-job/safe (list-jobs)) ;; #f from wait-condition-variable indicates a timeout (if (wait-condition-variable job-available pool-mutex) - (get-job (list-jobs)) + (get-job/safe (list-jobs)) #f)))) (if job-args (begin -- cgit v1.2.3