From 92686dda7c76e574d0a7fa447233e2ea7fd6ad59 Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Mon, 16 Jan 2012 14:47:33 +0400 Subject: [PATCH] net/http: fix data race in test Fixes #2712. R=golang-dev, dsymonds CC=golang-dev, mpimenov https://golang.org/cl/5543062 --- src/pkg/net/http/fs_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pkg/net/http/fs_test.go b/src/pkg/net/http/fs_test.go index 976ee75c7dd..8abd337cad8 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) }