mirror of
https://github.com/golang/go
synced 2024-11-13 18:20:32 -07:00
Use defer to unlock mutex in crypto/rand.
R=agl1 CC=golang-dev https://golang.org/cl/3991045
This commit is contained in:
parent
49e2888a96
commit
3921d26300
@ -29,15 +29,14 @@ type devReader struct {
|
||||
|
||||
func (r *devReader) Read(b []byte) (n int, err os.Error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
if r.f == nil {
|
||||
f, err := os.Open(r.name, os.O_RDONLY, 0)
|
||||
if f == nil {
|
||||
r.mu.Unlock()
|
||||
return 0, err
|
||||
}
|
||||
r.f = f
|
||||
}
|
||||
r.mu.Unlock()
|
||||
return r.f.Read(b)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user