From c43a8b8f35fd588e481fa2477a0e848b4983c981 Mon Sep 17 00:00:00 2001 From: mainzelm Date: Sun, 29 Dec 2002 19:09:37 +0000 Subject: [PATCH] Copy with-lock from scsh into sunet-utilities. --- scheme/lib/sunet-utilities.scm | 7 +++++++ scheme/packages.scm | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/scheme/lib/sunet-utilities.scm b/scheme/lib/sunet-utilities.scm index f6b8d45..ec617dd 100644 --- a/scheme/lib/sunet-utilities.scm +++ b/scheme/lib/sunet-utilities.scm @@ -68,3 +68,10 @@ (define (dump fd) (copy-inport->outport fd (current-output-port))) +(define (with-lock lock thunk) + (dynamic-wind + (lambda () + (release-lock lock)) + thunk + (lambda () + (release-lock lock)))) diff --git a/scheme/packages.scm b/scheme/packages.scm index 4f2ac66..b5b3cad 100644 --- a/scheme/packages.scm +++ b/scheme/packages.scm @@ -222,7 +222,8 @@ dump system-fqdn copy-inport->outport - dotdot-check)) + dotdot-check + with-lock)) (define-interface handle-fatal-error-interface (export with-fatal-error-handler* @@ -617,6 +618,7 @@ srfi-13 dns let-opt ; :optional + locks handle-fatal-error) (files (lib sunet-utilities)))