GNU bug report logs - #70494
[PATCH 00/23] Groundwork for the Guile guix-daemon

Previous Next

Package: guix-patches;

Reported by: Christopher Baines <mail <at> cbaines.net>

Date: Sun, 21 Apr 2024 09:37:01 UTC

Severity: normal

Tags: patch

Full log


Message #134 received at 70494 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Christopher Baines <mail <at> cbaines.net>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>, 70494 <at> debbugs.gnu.org,
 Simon Tournier <zimon.toutoune <at> gmail.com>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Tobias Geerinckx-Rice <me <at> tobias.gr>, Ricardo Wurmus <rekado <at> elephly.net>,
 Christopher Baines <guix <at> cbaines.net>
Subject: Re: [bug#70494] [PATCH 20/23] scripts: substitute: Simplify
 with-timeout usage.
Date: Thu, 16 May 2024 18:27:14 +0200
Christopher Baines <mail <at> cbaines.net> skribis:

> To reduce the codepaths in download-nar.
>
> * guix/scripts/substitute.scm (with-timeout): Accept a #f duration and don't
> set a timeout.
> (download-nar): Remove the if for fetch-timeout.
>
> Change-Id: I4e944a425a8612e96659dd84dd0e315012f080ab

[...]

>  (define-syntax-rule (with-timeout duration handler body ...)
>    "Run BODY; when DURATION seconds have expired, call HANDLER, and run BODY
>  again."

The docstring needs updating.

> +  (if duration
> +      (begin
> +        (sigaction SIGALRM
> +          (lambda (signum)
> +            (sigaction SIGALRM SIG_DFL)
> +            handler))
> +        (alarm duration)
> +        (call-with-values
> +            (lambda ()
> +              (let try ()
> +                (catch 'system-error
> +                  (lambda ()
> +                    body ...)
> +                  (lambda args
> +                    ;; Before Guile v2.0.9-39-gfe51c7b, the SIGALRM triggers EINTR
> +                    ;; because of the bug at
> +                    ;; <http://lists.gnu.org/archive/html/guile-devel/2013-06/msg00050.html>.
> +                    ;; When that happens, try again.  Note: SA_RESTART cannot be
> +                    ;; used because of <http://bugs.gnu.org/14640>.
> +                    (if (= EINTR (system-error-errno args))
> +                        (begin
> +                          ;; Wait a little to avoid bursts.
> +                          (usleep (random 3000000 %random-state))
> +                          (try))
> +                        (apply throw args))))))
> +          (lambda result
> +            (alarm 0)
> +            (sigaction SIGALRM SIG_DFL)
> +            (apply values result))))
> +      (begin
> +        body ...)))

To avoid code bloat due to expanding BODY twice, I think this should be
something like:

  (let ((thunk (lambda () body ...)))
    (if duration
        …
        (thunk)))

Otherwise LGTM.




This bug report was last modified 1 year and 28 days ago.

Previous Next


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