From: Brad Fitzpatrick Date: Sat, 30 Mar 2013 18:18:56 +0000 (-0700) Subject: net/http: fix incredibly racy TestTransportReading100Continue X-Git-Tag: go1.1rc2~252 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ad7aa8302011f08c2cac5291697704b352c2b735;p=gostls13.git net/http: fix incredibly racy TestTransportReading100Continue Whoops. I'm surprised it even worked before. (Need two pipes, not one.) Also, remove the whole pipe registration business, since it wasn't even required in the previous version. (I'd later fixed it at the end of send100Response, but forgot to delete it) R=golang-dev, r CC=golang-dev https://golang.org/cl/8191044 --- diff --git a/src/pkg/net/http/transport_test.go b/src/pkg/net/http/transport_test.go index 3caa3845de..75ab5dd7d8 100644 --- a/src/pkg/net/http/transport_test.go +++ b/src/pkg/net/http/transport_test.go @@ -1404,23 +1404,6 @@ func TestTransportSocketLateBinding(t *testing.T) { func TestTransportReading100Continue(t *testing.T) { defer afterTest(t) - var writers struct { - sync.Mutex - list []*io.PipeWriter - } - registerPipe := func(pw *io.PipeWriter) { - writers.Lock() - defer writers.Unlock() - writers.list = append(writers.list, pw) - } - defer func() { - writers.Lock() - defer writers.Unlock() - for _, pw := range writers.list { - pw.Close() - } - }() - const numReqs = 5 reqBody := func(n int) string { return fmt.Sprintf("request body %d", n) } reqID := func(n int) string { return fmt.Sprintf("REQ-ID-%d", n) } @@ -1463,13 +1446,13 @@ Content-Length: %d tr := &Transport{ Dial: func(n, addr string) (net.Conn, error) { - pr, pw := io.Pipe() - registerPipe(pw) + sr, sw := io.Pipe() // server read/write + cr, cw := io.Pipe() // client read/write conn := &rwTestConn{ - Reader: pr, - Writer: pw, + Reader: cr, + Writer: sw, } - go send100Response(pw, pr) + go send100Response(cw, sr) return conn, nil }, DisableKeepAlives: false,