GNU bug report logs - #76262
[PATCH 0/3] Remove uses of 'waitpid' in Shepherd services

Previous Next

Package: guix-patches;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Thu, 13 Feb 2025 11:45:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ludovic Courtès <ludo <at> gnu.org>
To: 76262 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [bug#76262] [PATCH 1/3] services: transmission: Remove custom ‘stop’ implementation.
Date: Thu, 13 Feb 2025 12:45:46 +0100
This ‘stop’ methods had two problems:

  1. It is incompatible with the Shepherd 1.0, where the running value
     is a <process> record and not a PID.

  2. It is unreliable because its ‘waitpid’ calls compete with those
     made by shepherd’s main event loop upon SIGCHLD.

* gnu/services/file-sharing.scm (transmission-daemon-shepherd-service):
Change ‘stop’ to use ‘make-kill-destructor’.

Change-Id: I406eb619d4a72bb5afe6200ac5c8f68736a78d97
---
 gnu/services/file-sharing.scm | 31 +++++--------------------------
 1 file changed, 5 insertions(+), 26 deletions(-)

diff --git a/gnu/services/file-sharing.scm b/gnu/services/file-sharing.scm
index 6b25cd420fd..4b6867bc070 100644
--- a/gnu/services/file-sharing.scm
+++ b/gnu/services/file-sharing.scm
@@ -648,33 +648,12 @@ (define (transmission-daemon-shepherd-service config)
                 #:log-file #$%transmission-daemon-log-file
                 #:environment-variables
                 '("CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt")))
-      (stop #~(lambda (pid)
-                (kill pid SIGTERM)
 
-                ;; Transmission Daemon normally needs some time to shut down,
-                ;; as it will complete some housekeeping and send a final
-                ;; update to trackers before it exits.
-                ;;
-                ;; Wait a reasonable period for it to stop before continuing.
-                ;; If we don't do this, restarting the service can fail as the
-                ;; new daemon process finds the old one still running and
-                ;; attached to the port used for peer connections.
-                (let wait-before-killing ((period #$stop-wait-period))
-                  (if (zero? (car (waitpid pid WNOHANG)))
-                      (if (positive? period)
-                          (begin
-                            (sleep 1)
-                            (wait-before-killing (- period 1)))
-                          (begin
-                            (format #t
-                                    #$(G_ "Wait period expired; killing \
-transmission-daemon (pid ~a).~%")
-                                    pid)
-                            (display #$(G_ "(If you see this message \
-regularly, you may need to increase the value
-of 'stop-wait-period' in the service configuration.)\n"))
-                            (kill pid SIGKILL)))))
-                #f))
+      ;; Transmission Daemon normally needs some time to shut down, as it will
+      ;; complete some housekeeping and send a final update to trackers before
+      ;; it exits.
+      (stop #~(make-kill-destructor #:grace-period #$stop-wait-period))
+
       (actions
        (list
         (shepherd-action
-- 
2.48.1





This bug report was last modified 91 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.