[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/07: services: shepherd: Remove ‘dynamic-wind’ in ‘call-with-*-file’.
From: |
guix-commits |
Subject: |
01/07: services: shepherd: Remove ‘dynamic-wind’ in ‘call-with-*-file’. |
Date: |
Fri, 5 Jan 2024 11:30:25 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 4e431fda5f2ec76b6d6a271be7c30b1324431329
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Jan 5 00:20:50 2024 +0100
services: shepherd: Remove ‘dynamic-wind’ in ‘call-with-*-file’.
Fixes <https://issues.guix.gnu.org/64653>.
The ‘dynamic-wind’ was causing files to be closed prematurely when
leaving the dynamic extent of PROC for instance via a delimited
continuation, using Fibers (that ‘dynamic-wind’ call was also
semantically incorrect in the first place).
* gnu/services/shepherd.scm (shepherd-configuration-file)
[config](call-with-file): Remove.
(call-with-input-file, call-with-output-file): Rewrite in terms of
‘call-with-port’.
Change-Id: Ica8af71a04f525a15be99985552063cb98cd6ee8
---
gnu/services/shepherd.scm | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index e9d3a631c2..8e122f1aab 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013-2016, 2018-2023 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013-2016, 2018-2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
;;; Copyright © 2018 Carlo Zancanaro <carlo@zancanaro.id.au>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
@@ -371,17 +371,6 @@ as shepherd package."
(use-modules (srfi srfi-34)
(system repl error-handling))
- (define (call-with-file file flags proc)
- (let ((port #f))
- (dynamic-wind
- (lambda ()
- (set! port (open file flags)))
- (lambda ()
- (proc port))
- (lambda ()
- (close-port port)
- (set! port #f)))))
-
;; There's code run from shepherd that uses 'call-with-input-file' &
;; co.--e.g., the 'urandom-seed' service. Starting from Shepherd
;; 0.9.2, users need to make sure not to leak non-close-on-exec file
@@ -389,12 +378,12 @@ as shepherd package."
;; standard bindings with O_CLOEXEC variants.
(set! call-with-input-file
(lambda (file proc)
- (call-with-file file (logior O_RDONLY O_CLOEXEC)
- proc)))
+ (call-with-port (open file (logior O_RDONLY O_CLOEXEC))
+ proc)))
(set! call-with-output-file
(lambda (file proc)
- (call-with-file file (logior O_WRONLY O_CREAT O_CLOEXEC)
- proc)))
+ (call-with-port (open file (logior O_WRONLY O_CREAT
O_CLOEXEC))
+ proc)))
;; Specify the default environment visible to all the services.
;; Without this statement, all the environment variables of PID 1
- branch master updated (5cec983e04 -> 5279bd453f), guix-commits, 2024/01/05
- 01/07: services: shepherd: Remove ‘dynamic-wind’ in ‘call-with-*-file’.,
guix-commits <=
- 05/07: gnu: Add guile-srfi-133., guix-commits, 2024/01/05
- 03/07: ui: It’s 2024 now!, guix-commits, 2024/01/05
- 02/07: teams: Add ‘core-packages’ team., guix-commits, 2024/01/05
- 04/07: daemon: Change default ‘timeout’ and ‘max-silent-time’ values., guix-commits, 2024/01/05
- 07/07: gnu: Add guile-srfi-232., guix-commits, 2024/01/05
- 06/07: services: xorg: ‘dbus-daemon-wrapper’ handles Home profile., guix-commits, 2024/01/05