Ver Fonte

http2: revert part of e7da8eda to fix data race it introduced

Git rev e7da8eda (CL 20542) introduced an optimization to reuse the
64k request body buffers across multiple requests. But ServeHTTP
handlers could retain them too long and cause races.

Temporarily revert the main part of that CL until a proper fix is in.

Updates golang/go#14960
Updates grpc/grpc-go#604

Change-Id: I28450e797a1d3122868214700b6ef345a0a1a47c
Reviewed-on: https://go-review.googlesource.com/21160
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Brad Fitzpatrick há 9 anos atrás
pai
commit
1600a4cd69
1 ficheiros alterados com 6 adições e 2 exclusões
  1. 6 2
      http2/server.go

+ 6 - 2
http2/server.go

@@ -1616,9 +1616,13 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res
 		Trailer:    trailer,
 	}
 	if bodyOpen {
-		st.reqBuf = sc.getRequestBodyBuf()
+		// Disabled, per golang.org/issue/14960:
+		// st.reqBuf = sc.getRequestBodyBuf()
+		// TODO: remove this 64k of garbage per request (again, but without a data race):
+		buf := make([]byte, initialWindowSize)
+
 		body.pipe = &pipe{
-			b: &fixedBuffer{buf: st.reqBuf},
+			b: &fixedBuffer{buf: buf},
 		}
 
 		if vv, ok := header["Content-Length"]; ok {