diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-07-11 22:42:41 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-07-11 22:42:41 +0200 |
commit | ce689ccf1802862cb425e30e9eea133b61ae0e03 (patch) | |
tree | 2476a9cd7c280f7f6c2b97f9758e14e338817735 | |
parent | 6a012c5f510a324ffe34ebf585f47fcd40ea63a3 (diff) | |
download | guix-ce689ccf1802862cb425e30e9eea133b61ae0e03.tar guix-ce689ccf1802862cb425e30e9eea133b61ae0e03.tar.gz |
substitute-binary: Directly replace the global `regexp-exec'.
* guix/scripts/substitute-binary.scm (%regexp-exec-mutex, string->uri):
Remove.
(regexp-exec): Replace this global binding by a thread-safety wrapper.
(fields->alist): Remove `with-mutex', and directly alias `recutils->alist'.
-rwxr-xr-x | guix/scripts/substitute-binary.scm | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/guix/scripts/substitute-binary.scm b/guix/scripts/substitute-binary.scm index e6244245d3..fbb5cf8337 100755 --- a/guix/scripts/substitute-binary.scm +++ b/guix/scripts/substitute-binary.scm @@ -87,23 +87,18 @@ output port, and PROC's result is returned." (lambda (key . args) (false-if-exception (delete-file template)))))) -(define %regexp-exec-mutex - ;; In Guile 2.0.9, `regexp-exec' is thread-unsafe, so work around it. - ;; See <http://bugs.gnu.org/14404>. - (make-mutex)) - -(define string->uri - (let ((real (@ (web uri) string->uri))) - (lambda (uri) - "A thread-safe `string->uri'." - (with-mutex %regexp-exec-mutex - (real uri))))) - -(define (fields->alist port) - "Read recutils-style record from PORT and return them as a list of key/value -pairs." - (with-mutex %regexp-exec-mutex - (recutils->alist port))) +;; In Guile 2.0.9, `regexp-exec' is thread-unsafe, so work around it. +;; See <http://bugs.gnu.org/14404>. +(set! regexp-exec + (let ((real regexp-exec) + (lock (make-mutex))) + (lambda args + (with-mutex lock + (apply real args))))) + +(define fields->alist + ;; The narinfo format is really just like recutils. + recutils->alist) (define %fetch-timeout ;; Number of seconds after which networking is considered "slow". |