Commit 3921d263 authored by Anschel Schaffer-Cohen's avatar Anschel Schaffer-Cohen Committed by Adam Langley

Use defer to unlock mutex in crypto/rand.

R=agl1
CC=golang-dev
https://golang.org/cl/3991045
parent 49e2888a
......@@ -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)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment