From: Dmitriy Vyukov Date: Mon, 16 Jan 2012 10:47:33 +0000 (+0400) Subject: net/http: fix data race in test X-Git-Tag: weekly.2012-01-20~101 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=92686dda7c76e574d0a7fa447233e2ea7fd6ad59;p=gostls13.git net/http: fix data race in test Fixes #2712. R=golang-dev, dsymonds CC=golang-dev, mpimenov https://golang.org/cl/5543062 --- diff --git a/src/pkg/net/http/fs_test.go b/src/pkg/net/http/fs_test.go index 976ee75c7d..8abd337cad 100644 --- a/src/pkg/net/http/fs_test.go +++ b/src/pkg/net/http/fs_test.go @@ -224,9 +224,9 @@ func TestEmptyDirOpenCWD(t *testing.T) { func TestServeFileContentType(t *testing.T) { const ctype = "icecream/chocolate" - override := false + override := make(chan bool, 1) ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - if override { + if <-override { w.Header().Set("Content-Type", ctype) } ServeFile(w, r, "testdata/file") @@ -241,8 +241,9 @@ func TestServeFileContentType(t *testing.T) { t.Errorf("Content-Type mismatch: got %q, want %q", h, want) } } + override <- false get("text/plain; charset=utf-8") - override = true + override <- true get(ctype) }