Skip to content

Commit

Permalink
Revert "Use backoff to be sure to be in sync when we update sources (@…
Browse files Browse the repository at this point in the history
…reynir)"

This reverts commit 37267b3.
  • Loading branch information
hannesm committed Mar 28, 2024
1 parent 37267b3 commit e8cb128
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
1 change: 0 additions & 1 deletion mirage-crypto-rng.opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ depends: [
"dune-configurator" {>= "2.0.0"}
"duration"
"logs"
"backoff"
"mirage-crypto" {=version}
"digestif" {>= "1.1.4"}
"ounit2" {with-test}
Expand Down
2 changes: 1 addition & 1 deletion rng/dune
Original file line number Diff line number Diff line change
@@ -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))
13 changes: 4 additions & 9 deletions rng/entropy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e8cb128

Please sign in to comment.