From 89ceb86ad415ea92450ebda60359a7ee0ec79eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 3 Jun 2019 16:24:31 +0200 Subject: [PATCH] syscalls: 'with-file-lock' expands to a call to 'call-with-file-lock'. * guix/build/syscalls.scm (call-with-file-lock): New procedure. (with-file-lock): Expand to a call to 'call-with-file-lock'. --- guix/build/syscalls.scm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 04fbebb8a2..3af41f2cf5 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -1083,17 +1083,19 @@ exception if it's already taken." (close-port port) #t) -(define-syntax-rule (with-file-lock file exp ...) - "Wait to acquire a lock on FILE and evaluate EXP in that context." +(define (call-with-file-lock file thunk) (let ((port (lock-file file))) (dynamic-wind (lambda () #t) - (lambda () - exp ...) + thunk (lambda () (unlock-file port))))) +(define-syntax-rule (with-file-lock file exp ...) + "Wait to acquire a lock on FILE and evaluate EXP in that context." + (call-with-file-lock file (lambda () exp ...))) + ;;; ;;; Miscellaneous, aka. 'prctl'.