]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: fix data race in test
authorDmitriy Vyukov <dvyukov@google.com>
Mon, 16 Jan 2012 10:47:33 +0000 (14:47 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Mon, 16 Jan 2012 10:47:33 +0000 (14:47 +0400)
Fixes #2712.

R=golang-dev, dsymonds
CC=golang-dev, mpimenov
https://golang.org/cl/5543062

src/pkg/net/http/fs_test.go

index 976ee75c7dd0710a1b6a99afcc5ab1935d14df57..8abd337cad81a00037dc9e10155358706749df8f 100644 (file)
@@ -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)
 }