From 9fe90a5c54e1bcded32597657d7381f9fa5adc74 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Tue, 2 Aug 2016 19:14:20 -0400 Subject: [PATCH] Release semaphore even in case of error --- src/static.rkt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/static.rkt b/src/static.rkt index 56ea8e8..406cbe9 100644 --- a/src/static.rkt +++ b/src/static.rkt @@ -172,9 +172,12 @@ (define (put/bytes^ p cb mt h) (semaphore-wait put-bytes-sema) (thread - (λ () - (put/bytes p cb mt h) - (semaphore-post put-bytes-sema)))) + (lambda () + (with-handlers ((values (lambda (e) + (semaphore-post put-bytes-sema) + (raise e)))) + (put/bytes p cb mt h) + (semaphore-post put-bytes-sema))))) (define (aws-put-file! index absolute-path content-bytes mime-type [headers '()]) (define relative-path (absolute-path->relative-path absolute-path))