Commit 21e37daa authored by Marius Nuennerich's avatar Marius Nuennerich Committed by Brad Fitzpatrick

io/ioutil: fix locking of the tempfile random state

Fixes #10451

Change-Id: I15ed777e9a4a4e1ba1178d07fcbe0ab4bf0d9e50
Reviewed-on: https://go-review.googlesource.com/8936Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent eced964c
......@@ -55,7 +55,9 @@ func TempFile(dir, prefix string) (f *os.File, err error) {
f, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
if os.IsExist(err) {
if nconflict++; nconflict > 10 {
randmu.Lock()
rand = reseed()
randmu.Unlock()
}
continue
}
......@@ -82,7 +84,9 @@ func TempDir(dir, prefix string) (name string, err error) {
err = os.Mkdir(try, 0700)
if os.IsExist(err) {
if nconflict++; nconflict > 10 {
randmu.Lock()
rand = reseed()
randmu.Unlock()
}
continue
}
......
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