mirror of
https://github.com/golang/go
synced 2024-11-23 21:30:08 -07:00
crypto/rand: fix race on r.used
This race is benign, but it still trips up the race detector, so turn this into an atomic read. Fixes #52739. Change-Id: Ib53362286b456513c8c69d6d2d73c6c90ec095f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/404475 Auto-Submit: Jason Donenfeld <Jason@zx2c4.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
2049649e8b
commit
091e913414
@ -59,7 +59,7 @@ func (r *reader) Read(b []byte) (n int, err error) {
|
||||
}
|
||||
if atomic.LoadUint32(&r.used) != 2 {
|
||||
r.mu.Lock()
|
||||
if r.used != 2 {
|
||||
if atomic.LoadUint32(&r.used) != 2 {
|
||||
f, err := os.Open(urandomDevice)
|
||||
if err != nil {
|
||||
r.mu.Unlock()
|
||||
|
Loading…
Reference in New Issue
Block a user