From d9c4f61574a87cc653cbcfcbe6952b5485891004 Mon Sep 17 00:00:00 2001
From: Matt Birkholz <puck@birchwood-abbey.net>
Date: Sun, 12 Jul 2015 15:10:53 -0700
Subject: [PATCH] mhash: Prepare the GC daemon to run concurrently with other
 threads.

---
 src/mhash/mhash.scm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/mhash/mhash.scm b/src/mhash/mhash.scm
index fc0da45a4..740123e08 100644
--- a/src/mhash/mhash.scm
+++ b/src/mhash/mhash.scm
@@ -115,10 +115,13 @@ USA.
 		(loop next prev)))))))
 
 (define (cleanup-mhash-contexts)
-  (if (not (thread-mutex-owner mhash-contexts-mutex))
-      (begin
-	(cleanup-contexts)
-	(cleanup-hmac-contexts))))
+  (with-thread-mutex-try-lock
+   mhash-contexts-mutex
+   (lambda ()
+     (cleanup-contexts)
+     (cleanup-hmac-contexts))
+   (lambda ()
+     unspecific)))
 
 (define (mhash-name->id name procedure)
   (let ((n (vector-length mhash-algorithm-names)))
-- 
2.25.1