aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
diff options
context:
space:
mode:
authorWayne Zuo <wdvxdr@golangcn.org>2022-10-24 12:13:56 +0800
committerWayne Zuo <wdvxdr@golangcn.org>2022-10-26 00:11:50 +0000
commit3dc13023c1d20ec48e2d0c69908b0a1cc3681462 (patch)
tree8bbe12fb123917d76e8eb4b7ed37dadee821c246 /src/net/http
parentb95ea201d54953055e7d5d29cf68bb5f19f21f93 (diff)
downloadgo-3dc13023c1d20ec48e2d0c69908b0a1cc3681462.tar.xz
all: update golang.org/x/tools to 8166dca1cec9
To pick up CL 443575. Note: This CL also update other x repositories because CL 444536 updates x/tools dependencies to latest tagged version. Done by go get -d golang.org/x/tools@8166dca1cec9 go mod tidy go mod vendor Change-Id: Ie2836bb4ebc1db0150ba240af4e2b750dbf1e0b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/445055 Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/net/http')
-rw-r--r--src/net/http/h2_bundle.go47
1 files changed, 33 insertions, 14 deletions
diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go
index 03b0f30b4b..32b628ad12 100644
--- a/src/net/http/h2_bundle.go
+++ b/src/net/http/h2_bundle.go
@@ -3863,7 +3863,7 @@ type http2Server struct {
}
func (s *http2Server) initialConnRecvWindowSize() int32 {
- if s.MaxUploadBufferPerConnection > http2initialWindowSize {
+ if s.MaxUploadBufferPerConnection >= http2initialWindowSize {
return s.MaxUploadBufferPerConnection
}
return 1 << 20
@@ -7172,8 +7172,8 @@ type http2clientStream struct {
readErr error // sticky read error; owned by transportResponseBody.Read
reqBody io.ReadCloser
- reqBodyContentLength int64 // -1 means unknown
- reqBodyClosed bool // body has been closed; guarded by cc.mu
+ reqBodyContentLength int64 // -1 means unknown
+ reqBodyClosed chan struct{} // guarded by cc.mu; non-nil on Close, closed when done
// owned by writeRequest:
sentEndStream bool // sent an END_STREAM flag to the peer
@@ -7213,9 +7213,8 @@ func (cs *http2clientStream) abortStreamLocked(err error) {
cs.abortErr = err
close(cs.abort)
})
- if cs.reqBody != nil && !cs.reqBodyClosed {
- cs.reqBody.Close()
- cs.reqBodyClosed = true
+ if cs.reqBody != nil {
+ cs.closeReqBodyLocked()
}
// TODO(dneil): Clean up tests where cs.cc.cond is nil.
if cs.cc.cond != nil {
@@ -7228,13 +7227,24 @@ func (cs *http2clientStream) abortRequestBodyWrite() {
cc := cs.cc
cc.mu.Lock()
defer cc.mu.Unlock()
- if cs.reqBody != nil && !cs.reqBodyClosed {
- cs.reqBody.Close()
- cs.reqBodyClosed = true
+ if cs.reqBody != nil && cs.reqBodyClosed == nil {
+ cs.closeReqBodyLocked()
cc.cond.Broadcast()
}
}
+func (cs *http2clientStream) closeReqBodyLocked() {
+ if cs.reqBodyClosed != nil {
+ return
+ }
+ cs.reqBodyClosed = make(chan struct{})
+ reqBodyClosed := cs.reqBodyClosed
+ go func() {
+ cs.reqBody.Close()
+ close(reqBodyClosed)
+ }()
+}
+
type http2stickyErrWriter struct {
conn net.Conn
timeout time.Duration
@@ -8261,11 +8271,19 @@ func (cs *http2clientStream) cleanupWriteRequest(err error) {
// and in multiple cases: server replies <=299 and >299
// while still writing request body
cc.mu.Lock()
+ mustCloseBody := false
+ if cs.reqBody != nil && cs.reqBodyClosed == nil {
+ mustCloseBody = true
+ cs.reqBodyClosed = make(chan struct{})
+ }
bodyClosed := cs.reqBodyClosed
- cs.reqBodyClosed = true
cc.mu.Unlock()
- if !bodyClosed && cs.reqBody != nil {
+ if mustCloseBody {
cs.reqBody.Close()
+ close(bodyClosed)
+ }
+ if bodyClosed != nil {
+ <-bodyClosed
}
if err != nil && cs.sentEndStream {
@@ -8445,7 +8463,7 @@ func (cs *http2clientStream) writeRequestBody(req *Request) (err error) {
}
if err != nil {
cc.mu.Lock()
- bodyClosed := cs.reqBodyClosed
+ bodyClosed := cs.reqBodyClosed != nil
cc.mu.Unlock()
switch {
case bodyClosed:
@@ -8540,7 +8558,7 @@ func (cs *http2clientStream) awaitFlowControl(maxBytes int) (taken int32, err er
if cc.closed {
return 0, http2errClientConnClosed
}
- if cs.reqBodyClosed {
+ if cs.reqBodyClosed != nil {
return 0, http2errStopReqBodyWrite
}
select {
@@ -8912,6 +8930,7 @@ func (rl *http2clientConnReadLoop) cleanup() {
err = io.ErrUnexpectedEOF
}
cc.closed = true
+
for _, cs := range cc.streams {
select {
case <-cs.peerClosed:
@@ -9861,7 +9880,7 @@ func http2traceGotConn(req *Request, cc *http2ClientConn, reused bool) {
cc.mu.Lock()
ci.WasIdle = len(cc.streams) == 0 && reused
if ci.WasIdle && !cc.lastActive.IsZero() {
- ci.IdleTime = time.Now().Sub(cc.lastActive)
+ ci.IdleTime = time.Since(cc.lastActive)
}
cc.mu.Unlock()