guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 02/05: service: One-short services really started once by 'st


From: Ludovic Courtès
Subject: [shepherd] 02/05: service: One-short services really started once by 'start-in-parallel'.
Date: Wed, 22 Mar 2023 18:40:09 -0400 (EDT)

civodul pushed a commit to branch master
in repository shepherd.

commit d1cdff990daf9c69ae386436c51146ed8de73b2f
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Mar 22 21:52:32 2023 +0100

    service: One-short services really started once by 'start-in-parallel'.
    
    This is a followup to f4c48666d41040fef8c1e9ee6c474f45139017a2, which
    was ineffective in some cases, such as with 'start-in-the-background' as
    shown in the test.
    
    * modules/shepherd/service.scm (start-in-parallel): Move 'hashq-set!'
    call before 'start'.
    * tests/one-shot.sh: Test it.
---
 modules/shepherd/service.scm |  4 ++--
 tests/one-shot.sh            | 13 ++++++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 4e85e52..0b27c03 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -647,11 +647,11 @@ while starting ~a: ~s")
                               (or (and (one-shot? service)
                                        (hashq-ref (%one-shot-services-started)
                                                   service))
-                                  (let ((result (start service)))
+                                  (begin
                                     (when (one-shot? service)
                                       (hashq-set! (%one-shot-services-started)
                                                   service #t))
-                                    result)))))
+                                    (start service))))))
                        (put-message channel (cons service value))))))
                 services)
       (let loop ((i (length services))
diff --git a/tests/one-shot.sh b/tests/one-shot.sh
index c595b38..5e9bc9b 100644
--- a/tests/one-shot.sh
+++ b/tests/one-shot.sh
@@ -73,6 +73,8 @@ cat > "$conf"<<EOF
    #:provides '(c)
    #:requires '(a b one-shotty)
    #:start (const #t)))
+
+(start-in-the-background '(a b c))
 EOF
 
 rm -f "$pid"
@@ -111,15 +113,20 @@ $herd status test-2 | grep started
 $herd stop test-2
 if test -f "$stamp-2"; then false; else true; fi
 
+# When starting A, B, and C via 'start-in-the-background', ONE-SHOTTY should
+# have been started once only.
+test $(grep "Starting service one-shotty" "$log" | wc -l) -eq 1
+$herd stop a
+
 # In the course of starting C, ONE-SHOTTY should be started only once.
 $herd start c
-test $(grep "Starting service one-shotty" "$log" | wc -l) -eq 1
+test $(grep "Starting service one-shotty" "$log" | wc -l) -eq 2
 
 # But we can still start it a second time, indirectly...
 $herd stop a
 $herd start c
-test $(grep "Starting service one-shotty" "$log" | wc -l) -eq 2
+test $(grep "Starting service one-shotty" "$log" | wc -l) -eq 3
 
 # ... and a third time, directly.
 $herd start one-shotty
-test $(grep "Starting service one-shotty" "$log" | wc -l) -eq 3
+test $(grep "Starting service one-shotty" "$log" | wc -l) -eq 4



reply via email to

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