]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: fix race in sendfile test
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 15 Feb 2012 22:27:26 +0000 (09:27 +1100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 15 Feb 2012 22:27:26 +0000 (09:27 +1100)
Whoops. Consume the body of the first request
before making the subsequent /quit request.

R=golang-dev, untheoretic
CC=golang-dev
https://golang.org/cl/5674054

src/pkg/net/http/fs_test.go

index 143617e95fc62c22a33e5a36b8b2075cc74cd077..f3e4a053e3bf942fb3a9a2dbf83afc9226520bc3 100644 (file)
@@ -398,11 +398,15 @@ func TestLinuxSendfile(t *testing.T) {
                return
        }
 
-       _, err = Get(fmt.Sprintf("http://%s/", ln.Addr()))
+       res, err := Get(fmt.Sprintf("http://%s/", ln.Addr()))
        if err != nil {
-               t.Errorf("http client error: %v", err)
-               return
+               t.Fatalf("http client error: %v", err)
+       }
+       _, err = io.Copy(ioutil.Discard, res.Body)
+       if err != nil {
+               t.Fatalf("client body read error: %v", err)
        }
+       res.Body.Close()
 
        // Force child to exit cleanly.
        Get(fmt.Sprintf("http://%s/quit", ln.Addr()))