Rusty Russell 3a2c0ba5ad hwrng: use reference counts on each struct hwrng.
current_rng holds one reference, and we bump it every time we want
to do a read from it.

This means we only hold the rng_mutex to grab or drop a reference,
so accessing /sys/devices/virtual/misc/hw_random/rng_current doesn't
block on read of /dev/hwrng.

Using a kref is overkill (we're always under the rng_mutex), but
a standard pattern.

This also solves the problem that the hwrng_fillfn thread was
accessing current_rng without a lock, which could change (eg. to NULL)
underneath it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2014-12-22 23:02:39 +11:00
..
2014-10-02 14:35:00 +08:00
2014-12-14 16:10:09 -08:00
2014-12-14 16:10:09 -08:00
2014-10-02 14:35:00 +08:00
2014-10-02 14:35:00 +08:00
2014-11-20 22:39:41 +08:00
2008-07-18 00:46:09 -07:00
2011-07-28 01:26:30 -07:00
2014-10-02 14:35:00 +08:00