mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-15 16:07:11 +08:00
vendor: golang.org/x/net v0.5.0
full diff: https://github.com/golang/net/compare/v0.4.0...v0.5.0 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
86
vendor/golang.org/x/net/http2/transport.go
generated
vendored
86
vendor/golang.org/x/net/http2/transport.go
generated
vendored
@ -47,10 +47,6 @@ const (
|
||||
// we buffer per stream.
|
||||
transportDefaultStreamFlow = 4 << 20
|
||||
|
||||
// transportDefaultStreamMinRefresh is the minimum number of bytes we'll send
|
||||
// a stream-level WINDOW_UPDATE for at a time.
|
||||
transportDefaultStreamMinRefresh = 4 << 10
|
||||
|
||||
defaultUserAgent = "Go-http-client/2.0"
|
||||
|
||||
// initialMaxConcurrentStreams is a connections maxConcurrentStreams until
|
||||
@ -310,8 +306,8 @@ type ClientConn struct {
|
||||
|
||||
mu sync.Mutex // guards following
|
||||
cond *sync.Cond // hold mu; broadcast on flow/closed changes
|
||||
flow flow // our conn-level flow control quota (cs.flow is per stream)
|
||||
inflow flow // peer's conn-level flow control
|
||||
flow outflow // our conn-level flow control quota (cs.outflow is per stream)
|
||||
inflow inflow // peer's conn-level flow control
|
||||
doNotReuse bool // whether conn is marked to not be reused for any future requests
|
||||
closing bool
|
||||
closed bool
|
||||
@ -376,10 +372,10 @@ type clientStream struct {
|
||||
respHeaderRecv chan struct{} // closed when headers are received
|
||||
res *http.Response // set if respHeaderRecv is closed
|
||||
|
||||
flow flow // guarded by cc.mu
|
||||
inflow flow // guarded by cc.mu
|
||||
bytesRemain int64 // -1 means unknown; owned by transportResponseBody.Read
|
||||
readErr error // sticky read error; owned by transportResponseBody.Read
|
||||
flow outflow // guarded by cc.mu
|
||||
inflow inflow // guarded by cc.mu
|
||||
bytesRemain int64 // -1 means unknown; owned by transportResponseBody.Read
|
||||
readErr error // sticky read error; owned by transportResponseBody.Read
|
||||
|
||||
reqBody io.ReadCloser
|
||||
reqBodyContentLength int64 // -1 means unknown
|
||||
@ -811,7 +807,7 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
|
||||
cc.bw.Write(clientPreface)
|
||||
cc.fr.WriteSettings(initialSettings...)
|
||||
cc.fr.WriteWindowUpdate(0, transportDefaultConnFlow)
|
||||
cc.inflow.add(transportDefaultConnFlow + initialWindowSize)
|
||||
cc.inflow.init(transportDefaultConnFlow + initialWindowSize)
|
||||
cc.bw.Flush()
|
||||
if cc.werr != nil {
|
||||
cc.Close()
|
||||
@ -2073,8 +2069,7 @@ type resAndError struct {
|
||||
func (cc *ClientConn) addStreamLocked(cs *clientStream) {
|
||||
cs.flow.add(int32(cc.initialWindowSize))
|
||||
cs.flow.setConnFlow(&cc.flow)
|
||||
cs.inflow.add(transportDefaultStreamFlow)
|
||||
cs.inflow.setConnFlow(&cc.inflow)
|
||||
cs.inflow.init(transportDefaultStreamFlow)
|
||||
cs.ID = cc.nextStreamID
|
||||
cc.nextStreamID += 2
|
||||
cc.streams[cs.ID] = cs
|
||||
@ -2533,21 +2528,10 @@ func (b transportResponseBody) Read(p []byte) (n int, err error) {
|
||||
}
|
||||
|
||||
cc.mu.Lock()
|
||||
var connAdd, streamAdd int32
|
||||
// Check the conn-level first, before the stream-level.
|
||||
if v := cc.inflow.available(); v < transportDefaultConnFlow/2 {
|
||||
connAdd = transportDefaultConnFlow - v
|
||||
cc.inflow.add(connAdd)
|
||||
}
|
||||
connAdd := cc.inflow.add(n)
|
||||
var streamAdd int32
|
||||
if err == nil { // No need to refresh if the stream is over or failed.
|
||||
// Consider any buffered body data (read from the conn but not
|
||||
// consumed by the client) when computing flow control for this
|
||||
// stream.
|
||||
v := int(cs.inflow.available()) + cs.bufPipe.Len()
|
||||
if v < transportDefaultStreamFlow-transportDefaultStreamMinRefresh {
|
||||
streamAdd = int32(transportDefaultStreamFlow - v)
|
||||
cs.inflow.add(streamAdd)
|
||||
}
|
||||
streamAdd = cs.inflow.add(n)
|
||||
}
|
||||
cc.mu.Unlock()
|
||||
|
||||
@ -2575,17 +2559,15 @@ func (b transportResponseBody) Close() error {
|
||||
if unread > 0 {
|
||||
cc.mu.Lock()
|
||||
// Return connection-level flow control.
|
||||
if unread > 0 {
|
||||
cc.inflow.add(int32(unread))
|
||||
}
|
||||
connAdd := cc.inflow.add(unread)
|
||||
cc.mu.Unlock()
|
||||
|
||||
// TODO(dneil): Acquiring this mutex can block indefinitely.
|
||||
// Move flow control return to a goroutine?
|
||||
cc.wmu.Lock()
|
||||
// Return connection-level flow control.
|
||||
if unread > 0 {
|
||||
cc.fr.WriteWindowUpdate(0, uint32(unread))
|
||||
if connAdd > 0 {
|
||||
cc.fr.WriteWindowUpdate(0, uint32(connAdd))
|
||||
}
|
||||
cc.bw.Flush()
|
||||
cc.wmu.Unlock()
|
||||
@ -2628,13 +2610,18 @@ func (rl *clientConnReadLoop) processData(f *DataFrame) error {
|
||||
// But at least return their flow control:
|
||||
if f.Length > 0 {
|
||||
cc.mu.Lock()
|
||||
cc.inflow.add(int32(f.Length))
|
||||
ok := cc.inflow.take(f.Length)
|
||||
connAdd := cc.inflow.add(int(f.Length))
|
||||
cc.mu.Unlock()
|
||||
|
||||
cc.wmu.Lock()
|
||||
cc.fr.WriteWindowUpdate(0, uint32(f.Length))
|
||||
cc.bw.Flush()
|
||||
cc.wmu.Unlock()
|
||||
if !ok {
|
||||
return ConnectionError(ErrCodeFlowControl)
|
||||
}
|
||||
if connAdd > 0 {
|
||||
cc.wmu.Lock()
|
||||
cc.fr.WriteWindowUpdate(0, uint32(connAdd))
|
||||
cc.bw.Flush()
|
||||
cc.wmu.Unlock()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -2665,9 +2652,7 @@ func (rl *clientConnReadLoop) processData(f *DataFrame) error {
|
||||
}
|
||||
// Check connection-level flow control.
|
||||
cc.mu.Lock()
|
||||
if cs.inflow.available() >= int32(f.Length) {
|
||||
cs.inflow.take(int32(f.Length))
|
||||
} else {
|
||||
if !takeInflows(&cc.inflow, &cs.inflow, f.Length) {
|
||||
cc.mu.Unlock()
|
||||
return ConnectionError(ErrCodeFlowControl)
|
||||
}
|
||||
@ -2689,19 +2674,20 @@ func (rl *clientConnReadLoop) processData(f *DataFrame) error {
|
||||
}
|
||||
}
|
||||
|
||||
if refund > 0 {
|
||||
cc.inflow.add(int32(refund))
|
||||
if !didReset {
|
||||
cs.inflow.add(int32(refund))
|
||||
}
|
||||
sendConn := cc.inflow.add(refund)
|
||||
var sendStream int32
|
||||
if !didReset {
|
||||
sendStream = cs.inflow.add(refund)
|
||||
}
|
||||
cc.mu.Unlock()
|
||||
|
||||
if refund > 0 {
|
||||
if sendConn > 0 || sendStream > 0 {
|
||||
cc.wmu.Lock()
|
||||
cc.fr.WriteWindowUpdate(0, uint32(refund))
|
||||
if !didReset {
|
||||
cc.fr.WriteWindowUpdate(cs.ID, uint32(refund))
|
||||
if sendConn > 0 {
|
||||
cc.fr.WriteWindowUpdate(0, uint32(sendConn))
|
||||
}
|
||||
if sendStream > 0 {
|
||||
cc.fr.WriteWindowUpdate(cs.ID, uint32(sendStream))
|
||||
}
|
||||
cc.bw.Flush()
|
||||
cc.wmu.Unlock()
|
||||
|
Reference in New Issue
Block a user