services: herd: 'with-shepherd' no longer leaves an open connection.

* gnu/services/herd.scm (with-shepherd): Use 'dynamic-wind' and close
CONNECTION at the end.
master
Ludovic Courtès 2018-01-21 00:19:24 +01:00
parent 30875d07ef
commit 89a2647816
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
@ -83,7 +83,12 @@ return the socket."
(define-syntax-rule (with-shepherd connection body ...) (define-syntax-rule (with-shepherd connection body ...)
"Evaluate BODY... with CONNECTION bound to an open socket to PID 1." "Evaluate BODY... with CONNECTION bound to an open socket to PID 1."
(let ((connection (open-connection))) (let ((connection (open-connection)))
body ...)) (dynamic-wind
(const #t)
(lambda ()
body ...)
(lambda ()
(close-port connection)))))
(define-condition-type &shepherd-error &error (define-condition-type &shepherd-error &error
shepherd-error?) shepherd-error?)