From 5db4077e9f5166033637d2af9532ec6144b85646 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Thu, 30 Jun 2022 14:21:47 +0000 Subject: [PATCH 1/2] Fix behaviour of 'epoll-wake!' after 'run-fibers'. This avoids the "epoll instance is dead" error noticed in GNUnet-Scheme's test suite, as reported at . A test is added in the next commit. This patch has been applied upstream, but there hasn't been a new release yet at time of writing. * fibers/epoll.scm (epoll-wake!)[dead]: Instead of throwing an error, just return #t. --- fibers/epoll.scm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fibers/epoll.scm b/fibers/epoll.scm index d26db4d..eb63242 100644 --- a/fibers/epoll.scm +++ b/fibers/epoll.scm @@ -1,6 +1,7 @@ ;; epoll ;;;; Copyright (C) 2016 Andy Wingo +;;;; Copyright (C) 2022 Maxime Devos ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -135,7 +136,12 @@ epoll wait (if appropriate)." ('waiting (primitive-epoll-wake (fileno (epoll-wake-write-pipe epoll)))) ('not-waiting #t) - ('dead (error "epoll instance is dead")))) + ;; This can happen if a fiber was waiting on a condition and + ;; run-fibers completes before the fiber completes and afterwards + ;; the condition is signalled. In that case, we don't have to + ;; resurrect the fiber or something, we can just do nothing. + ;; (Bug report: https://github.com/wingo/fibers/issues/61) + ('dead #t))) (define (epoll-default-folder fd events seed) (acons fd events seed)) From c01d3853eb56ea4adacc31f51f6e917f8c0abe1c Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Thu, 30 Jun 2022 14:18:36 +0000 Subject: [PATCH 2/2] Test for issue #61. * tests/conditions.scm: Add a test. --- tests/conditions.scm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/conditions.scm b/tests/conditions.scm index 505c42a..179605a 100644 --- a/tests/conditions.scm +++ b/tests/conditions.scm @@ -1,6 +1,7 @@ ;; Fibers: cooperative, event-driven user-space threads. ;;;; Copyright (C) 2016 Free Software Foundation, Inc. +;;;; Copyright (C) 2022 Maxime Devos ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -21,6 +22,7 @@ #:use-module (fibers) #:use-module (fibers conditions) #:use-module (fibers operations) + #:use-module (fibers scheduler) #:use-module (fibers timers)) (define failed? #f) @@ -78,4 +80,22 @@ (wait cv) #t)) +;; Make a condition, wait for it inside a fiber, let the fiber abruptly +;; terminate and signal the condition afterwards. This tests for the bug +;; noticed at . +(assert-equal #t + (let ((cv (make-condition))) + (run-fibers + (lambda () + (spawn-fiber (lambda () (wait cv))) + (yield-current-task)) ; let the other fiber wait forever + ;; This test relies on not draining -- this is the default, + ;; but let's make this explicit. + #:drain? #false ; + ;; For simplicity, disable concurrency and preemption. + ;; That way, we can use 'yield-current-task' instead of an + ;; arbitrary sleep time. + #:hz 0 #:parallelism 1) + (signal-condition! cv))) + (exit (if failed? 1 0)) , try the /lzip URL. Fixes <https://issues.guix.gnu.org/63634>. * guix/narinfo.scm (narinfo-preferred-uris): New procedure. (narinfo-best-uri): Rebase on top of it. * guix/scripts/substitute.scm (download-nar)[try-fetch]: New procedure. Use 'narinfo-preferred-uris' and 'try-fetch' to attempt all the URLs of NARINFO. * tests/substitute.scm (request-substitution): Remove 'parameterize'. Delete DESTINATION. ("substitute, preferred nar URL is 404, other is 200"): New test. Ludovic Courtès 2022-09-28substitute: Retry downloading when a nar is unavailable....Fixes <https://issues.guix.gnu.org/57978> Reported by Attila Lendvai <attila@lendvai.name>. Previously, if a narinfo was available but its corresponding nar was missing (for instance because the narinfo was cached and the server became unreachable in the meantime), 'guix substitute --substitute' would try to download the nar from its preferred location and abort when that fails. This change forces one retry with each of the URLs. * guix/scripts/substitute.scm (download-nar): Do not catch 'http-get-error?' exceptions. (system-error?, network-error?, process-substitution/fallback): New procedures. (process-substitution): Call 'process-substitution/fallback' upon 'network-error?'. * tests/substitute.scm ("substitute, first URL has narinfo but lacks nar, second URL unauthorized") ("substitute, first URL has narinfo but nar is 404, both URLs authorized") ("substitute, first URL has narinfo but nar is 404, one URL authorized") ("substitute, narinfo is available but nar is missing"): New tests. Ludovic Courtès 2022-09-24substitute: Test behavior with unroutable substitute server addresses....* tests/substitute.scm (%unroutable-substitute-url): New variable. ("query narinfo signed with authorized key, unroutable URL first") ("substitute, authorized key, first substitute URL is unroutable"): New tests. Ludovic Courtès 2022-02-14publish: Do not sign the URL/Compression/FileSize narinfo fields....This will allow mirror operators to alter these non-normative bits of a narinfo without having to resign narinfos. * guix/scripts/publish.scm (narinfo-string): Remove URL/Compression/FileSize from BASE-INFO. Move them after "Signature". * tests/publish.scm ("/*.narinfo") ("/*.narinfo with properly encoded '+' sign") ("/*.narinfo with lzip + gzip") ("with cache, lzip + gzip"): Adjust accordingly. * tests/substitute.scm ("query narinfo with signature over relevant subset"): New test. Ludovic Courtès