]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/api: fix race in run.go with multiple builders on a machine
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 22 Dec 2014 19:16:04 +0000 (11:16 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 22 Dec 2014 19:40:32 +0000 (19:40 +0000)
Fixes #9407

Change-Id: I765e8009c7ee22473ac8c2d81c7f6c8ec9866c51
Reviewed-on: https://go-review.googlesource.com/1980
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/api/run.go

index c2c665014cb84a61331ba4a2cc73a46e11d85694..fb4cf785514c3ae6015c720c34510ca280c8c5fa 100644 (file)
@@ -92,7 +92,12 @@ func file(s ...string) string {
 // It tries to re-use a go.tools checkout from a previous run if possible,
 // else it hg clones it.
 func prepGoPath() string {
-       const tempBase = "go.tools.TMP"
+       // Use a builder-specific temp directory name, so builders running
+       // two copies don't trample on each other: https://golang.org/issue/9407
+       // We don't use io.TempDir or a PID or timestamp here because we do
+       // want this to be stable between runs, to minimize "git clone" calls
+       // in the common case.
+       var tempBase = fmt.Sprintf("go.tools.TMP.%s.%s", runtime.GOOS, runtime.GOARCH)
 
        username := ""
        u, err := user.Current()