guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 07/12: service: 'service-running-value' uses a fresh channel


From: Ludovic Courtès
Subject: [shepherd] 07/12: service: 'service-running-value' uses a fresh channel for each reply.
Date: Sun, 19 Feb 2023 16:58:37 -0500 (EST)

civodul pushed a commit to branch wip-service-monitor
in repository shepherd.

commit a460085e302108e2d7a77833d7f93028f53df302
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun Feb 19 16:04:56 2023 +0100

    service: 'service-running-value' uses a fresh channel for each reply.
    
    This avoids confusion if 'service-running-value' might be called from
    different fibers concurrently.
    
    * modules/shepherd/service.scm (service-running-value): Use a fresh
    channel for each reply.
---
 modules/shepherd/service.scm | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 34e23b1..f88781c 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -336,15 +336,14 @@ wire."
 (define-method (canonical-name (obj <service>))
   (car (provided-by obj)))
 
-(define service-running-value
+(define (service-running-value service)
+  "Return the \"running value\" of SERVICE."
   (let ((reply (make-channel)))
-    (lambda (service)
-      "Return the \"running value\" of SERVICE."
-      (put-message (current-monitor-channel)
-                   `(running ,service ,reply))
-      (match (get-message reply)
-        ((? procedure? proc) (proc))
-        (value value)))))
+    (put-message (service-control service)
+                 `(running ,reply))
+    (match (get-message reply)
+      ((? procedure? proc) (proc))
+      (value value))))
 
 ;; Return whether the service is currently running.
 (define-method (running? (obj <service>))



reply via email to

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