guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[shepherd] 03/06: shepherd: Simplify 'call-with-server-socket'.


From: Ludovic Courtès
Subject: [shepherd] 03/06: shepherd: Simplify 'call-with-server-socket'.
Date: Mon, 12 Jun 2023 09:39:21 -0400 (EDT)

civodul pushed a commit to branch master
in repository shepherd.

commit c3414435a2fab6afd68442f39e91b449c533c809
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun Jun 11 10:35:32 2023 +0200

    shepherd: Simplify 'call-with-server-socket'.
    
    * modules/shepherd.scm (unwind-protect): Remove.
    (call-with-server-socket): Use 'catch #t' rather than 'unwind-protect'.
    Remove call to 'delete-file'.
---
 modules/shepherd.scm | 30 +++++++-----------------------
 1 file changed, 7 insertions(+), 23 deletions(-)

diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index d2e5f39..7058e6b 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -42,25 +42,6 @@
 
 (define sleep (@ (fibers) sleep))
 
-(define-syntax-rule (unwind-protect body ... conclude)
-  "Evaluate BODY... and return its result(s), but always evaluate CONCLUDE
-before leaving, even if an exception is raised.
-
-This is *not* implemented with 'dynamic-wind' in order to play well with
-delimited continuations and fibers."
-  (let ((conclusion (lambda () conclude)))
-    (catch #t
-      (lambda ()
-        (call-with-values
-            (lambda ()
-              body ...)
-          (lambda results
-            (conclusion)
-            (apply values results))))
-      (lambda args
-        (conclusion)
-        (apply throw args)))))
-
 (define (call-with-server-socket file-name proc)
   "Call PROC, passing it a listening socket at FILE-NAME and deleting the
 socket file at FILE-NAME upon exit of PROC.  Return the values of PROC."
@@ -76,10 +57,13 @@ socket file at FILE-NAME upon exit of PROC.  Return the 
values of PROC."
                      ;; Stop services that were started from the config file
                      ;; and quit.
                      (stop-service root-service)))))))
-    (unwind-protect (proc sock)
-                    (begin
-                      (close sock)
-                      (catch-system-error (delete-file file-name))))))
+    (and sock
+         (catch #t
+           (lambda ()
+             (proc sock))
+           (lambda args
+             (close sock)
+             (apply throw args))))))
 
 (define (maybe-signal-port signals)
   "Return a signal port for SIGNALS, using 'signalfd' on GNU/Linux, or #f if



reply via email to

[Prev in Thread] Current Thread [Next in Thread]