From 26c29bd09bb13578d0efed97b0e9303c26ac5e09 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 16 Apr 2024 12:17:42 +0100 Subject: Add exception handling to the addition processing channel --- nar-herder/server.scm | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/nar-herder/server.scm b/nar-herder/server.scm index 2b941b9..fecf166 100644 --- a/nar-herder/server.scm +++ b/nar-herder/server.scm @@ -810,26 +810,32 @@ (spawn-fiber (lambda () (while #t - (match (get-message addition-channel) - (('addition file) - (when mirror-channel - (put-message mirror-channel - `(fetch ,file))) - (when removal-channel - (spawn-fiber - (lambda () - (sleep 60) - (removal-channel-remove-nar-from-storage removal-channel - file) - (sleep (* 5 60)) - (removal-channel-remove-nar-from-storage removal-channel - file) - (sleep (* 15 60)) - (removal-channel-remove-nar-from-storage removal-channel - file) - (sleep 3600) - (removal-channel-remove-nar-from-storage removal-channel - file))))))))) + (with-exception-handler + (lambda (exn) + (log-msg 'ERROR "exception processing addition-channel: " + exn)) + (lambda () + (match (get-message addition-channel) + (('addition file) + (when mirror-channel + (put-message mirror-channel + `(fetch ,file))) + (when removal-channel + (spawn-fiber + (lambda () + (sleep 60) + (removal-channel-remove-nar-from-storage removal-channel + file) + (sleep (* 5 60)) + (removal-channel-remove-nar-from-storage removal-channel + file) + (sleep (* 15 60)) + (removal-channel-remove-nar-from-storage removal-channel + file) + (sleep 3600) + (removal-channel-remove-nar-from-storage removal-channel + file))))))) + #:unwind? #t)))) (start-recent-change-listener-fiber database -- cgit v1.2.3