mirror of
https://github.com/golang/go
synced 2024-09-29 07:24:32 -06:00
testing: increment tempDirSeq non-atomically
It's unnecessary to to call atomic.AddInt32 since there is a mutex lock. Change-Id: I31fcece17c34f99a95772d744aebd3f6a8cf1d23 Reviewed-on: https://go-review.googlesource.com/c/go/+/426081 Reviewed-by: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
3c6a5cdb9a
commit
8a3d167f5b
@ -1127,12 +1127,17 @@ func (c *common) TempDir() string {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if c.tempDirErr == nil {
|
||||
c.tempDirSeq++
|
||||
}
|
||||
seq := c.tempDirSeq
|
||||
c.tempDirMu.Unlock()
|
||||
|
||||
if c.tempDirErr != nil {
|
||||
c.Fatalf("TempDir: %v", c.tempDirErr)
|
||||
}
|
||||
seq := atomic.AddInt32(&c.tempDirSeq, 1)
|
||||
|
||||
dir := fmt.Sprintf("%s%c%03d", c.tempDir, os.PathSeparator, seq)
|
||||
if err := os.Mkdir(dir, 0777); err != nil {
|
||||
c.Fatalf("TempDir: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user