From 549014b57cda7aa65e887718d8e7442c78af0773 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Thu, 9 Jul 2015 19:15:07 -0700 Subject: [PATCH] gdbm: Assume other threads may run concurrently with the GC daemons. --- src/gdbm/gdbm.scm | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/gdbm/gdbm.scm b/src/gdbm/gdbm.scm index b94adc545..f4566096e 100644 --- a/src/gdbm/gdbm.scm +++ b/src/gdbm/gdbm.scm @@ -345,23 +345,27 @@ USA. (loop (cdr alist))))))) (define (cleanup-open-gdbfs) - (if (not (thread-mutex-owner open-gdbfs-mutex)) - (let loop ((entries open-gdbfs) - (prev #f)) - (if (pair? entries) - (let ((entry (car entries)) - (next (cdr entries))) - (if (weak-pair/car? entry) - (loop next entries) - (let ((args (weak-cdr entry))) - (if prev - (set-cdr! prev next) - (set! open-gdbfs next)) - (if (not (alien-null? args)) - (begin - (C-call "do_gdbm_close" args) - (alien-null! args))) - (loop next prev)))))))) + (with-thread-mutex-lock-try + open-gdbfs-mutex + (lambda () + (let loop ((entries open-gdbfs) + (prev #f)) + (if (pair? entries) + (let ((entry (car entries)) + (next (cdr entries))) + (if (weak-pair/car? entry) + (loop next entries) + (let ((args (weak-cdr entry))) + (if prev + (set-cdr! prev next) + (set! open-gdbfs next)) + (if (not (alien-null? args)) + (begin + (C-call "do_gdbm_close" args) + (alien-null! args))) + (loop next prev))))))) + (lambda () + unspecific))) (define (reset-open-gdbfs) (for-each (lambda (weak) (alien-null! (weak-cdr weak))) open-gdbfs) -- 2.25.1