guix-commits
[Top][All Lists]
Advanced

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

[shepherd] branch master updated: service: 'shutdown-services' no longer


From: Ludovic Courtès
Subject: [shepherd] branch master updated: service: 'shutdown-services' no longer introduces a continuation barrier.
Date: Mon, 14 Nov 2022 11:25:10 -0500

This is an automated email from the git hooks/post-receive script.

civodul pushed a commit to branch master
in repository shepherd.

The following commit(s) were added to refs/heads/master by this push:
     new ada8807  service: 'shutdown-services' no longer introduces a 
continuation barrier.
ada8807 is described below

commit ada88074f0ab7551fd0f3dce8bf06de971382e79
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Nov 14 17:05:05 2022 +0100

    service: 'shutdown-services' no longer introduces a continuation barrier.
    
    * modules/shepherd/service.scm (shutdown-services): Use 'for-each' and
    'service-list' instead of 'for-each-service'.
    * tests/system-star.sh: Test it.
---
 modules/shepherd/service.scm |  8 ++++++--
 tests/system-star.sh         | 11 +++++++----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 9e31571..7779b8a 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -2028,14 +2028,18 @@ requested to be removed."
   "Shut down all the currently running services; update the persistent state
 file when persistence is enabled."
   (let ((running-services '()))
-    (for-each-service
+    ;; Note: Do not use 'for-each-service' since it introduces a continuation
+    ;; barrier via 'hash-fold', thereby preventing the 'stop' method from
+    ;; suspending via (@ (fibers) sleep), 'spawn-command', or similar.
+    (for-each
      (lambda (service)
        (when (running? service)
          (stop service)
          (when persistency
            (set! running-services
                  (cons (canonical-name service)
-                       running-services))))))
+                       running-services)))))
+     (service-list))
 
     (when persistency
       (call-with-output-file persistency-state-file
diff --git a/tests/system-star.sh b/tests/system-star.sh
index 895525e..15ff522 100755
--- a/tests/system-star.sh
+++ b/tests/system-star.sh
@@ -50,8 +50,10 @@ cat > "$conf" <<EOF
              (list "$SHELL" "-cex"
                    "[ ! -f $PWD/$stamp ] ; touch $PWD/$stamp ; sleep 60"))
    #:stop  (lambda (pid)
-             (delete-file "$stamp")
-             (zero? (system* "$(type -P kill)" (number->string pid))))
+             (and (zero? (system* "$(type -P kill)" (number->string pid)))
+                  (begin
+                    (delete-file "$stamp")
+                    #f)))
    #:respawn? #t))
 EOF
 
@@ -105,7 +107,8 @@ do
     $herd restart test-with-respawn
     $herd status test-with-respawn | grep "started"
 done
-$herd stop test-with-respawn
-$herd status test-with-respawn | grep "stopped"
 
 $herd stop root
+
+# Make sure 'shutdown-services' did its job.
+! test -f "$stamp"



reply via email to

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