diff options
author | Ludovic Courtès <ludo@gnu.org> | 2019-06-03 16:24:31 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2019-06-05 23:10:36 +0200 |
commit | 89ceb86ad415ea92450ebda60359a7ee0ec79eb6 (patch) | |
tree | b0ca73a8f3703f37318d5e2e175b11b0ed770874 | |
parent | b7178c22bf642919345095aff9e34e02c00d5762 (diff) | |
download | patches-89ceb86ad415ea92450ebda60359a7ee0ec79eb6.tar patches-89ceb86ad415ea92450ebda60359a7ee0ec79eb6.tar.gz |
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'.
-rw-r--r-- | guix/build/syscalls.scm | 10 |
1 files 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'. |