[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
- [shepherd] branch master updated (0703196 -> 24c9640), Ludovic Courtès, 2023/06/12
- [shepherd] 04/06: comm: 'open-server-socket' deletes the file before binding., Ludovic Courtès, 2023/06/12
- [shepherd] 02/06: shepherd: Spawn signal-handling fiber early on., Ludovic Courtès, 2023/06/12
- [shepherd] 01/06: service: 'service' errors out when 'provision' is invalid., Ludovic Courtès, 2023/06/12
- [shepherd] 03/06: shepherd: Simplify 'call-with-server-socket'.,
Ludovic Courtès <=
- [shepherd] 05/06: service: Add 'respawn-limit' slot to <service>., Ludovic Courtès, 2023/06/12
- [shepherd] 06/06: shepherd: Load config asynchronously and gracefully handle errors., Ludovic Courtès, 2023/06/12