From e8cb1281e76dba0692594491d7e95e3ed85761c3 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Thu, 28 Mar 2024 16:22:47 +0100 Subject: [PATCH] Revert "Use backoff to be sure to be in sync when we update sources (@reynir)" This reverts commit 37267b35227ebc7fe9aee19a3375b7b5a7b9d560. --- mirage-crypto-rng.opam | 1 - rng/dune | 2 +- rng/entropy.ml | 13 ++++--------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/mirage-crypto-rng.opam b/mirage-crypto-rng.opam index 35acbbd7..b8f4471d 100644 --- a/mirage-crypto-rng.opam +++ b/mirage-crypto-rng.opam @@ -18,7 +18,6 @@ depends: [ "dune-configurator" {>= "2.0.0"} "duration" "logs" - "backoff" "mirage-crypto" {=version} "digestif" {>= "1.1.4"} "ounit2" {with-test} diff --git a/rng/dune b/rng/dune index 8ae2c924..e70f9743 100644 --- a/rng/dune +++ b/rng/dune @@ -1,5 +1,5 @@ (library (name mirage_crypto_rng) (public_name mirage-crypto-rng) - (libraries mirage-crypto backoff digestif) + (libraries mirage-crypto digestif) (private_modules entropy fortuna hmac_drbg rng)) diff --git a/rng/entropy.ml b/rng/entropy.ml index 46bf492f..008bdb80 100644 --- a/rng/entropy.ml +++ b/rng/entropy.ml @@ -55,15 +55,10 @@ let _sources = Atomic.make S.empty type source = Rng.source let register_source name = - let rec go backoff = - let seen = Atomic.get _sources in - let n = S.cardinal seen in - let source = (n, name) in - let after = S.add source (Atomic.get _sources) in - if Atomic.compare_and_set _sources seen after = false - then go (Backoff.once backoff) - else source in - go Backoff.default + let n = S.cardinal (Atomic.get _sources) in + let source = (n, name) in + Atomic.set _sources (S.add source (Atomic.get _sources)); + source let id (idx, _) = idx