Skip to content

Commit d73acff

Browse files
panjf2000gopherbot
authored andcommitted
http2: only set up deadline when Server.IdleTimeout is positive
Check out https://go-review.googlesource.com/c/go/+/570396 Change-Id: I8bda17acebc27308c2a1723191ea1e4a9e64d585 Reviewed-on: https://go-review.googlesource.com/c/net/+/570455 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-by: Damien Neil <[email protected]> Auto-Submit: Damien Neil <[email protected]>
1 parent 89f602b commit d73acff

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: http2/server.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ type Server struct {
124124
// IdleTimeout specifies how long until idle clients should be
125125
// closed with a GOAWAY frame. PING frames are not considered
126126
// activity for the purposes of IdleTimeout.
127+
// If zero or negative, there is no timeout.
127128
IdleTimeout time.Duration
128129

129130
// MaxUploadBufferPerConnection is the size of the initial flow
@@ -924,7 +925,7 @@ func (sc *serverConn) serve() {
924925
sc.setConnState(http.StateActive)
925926
sc.setConnState(http.StateIdle)
926927

927-
if sc.srv.IdleTimeout != 0 {
928+
if sc.srv.IdleTimeout > 0 {
928929
sc.idleTimer = time.AfterFunc(sc.srv.IdleTimeout, sc.onIdleTimer)
929930
defer sc.idleTimer.Stop()
930931
}
@@ -1637,7 +1638,7 @@ func (sc *serverConn) closeStream(st *stream, err error) {
16371638
delete(sc.streams, st.id)
16381639
if len(sc.streams) == 0 {
16391640
sc.setConnState(http.StateIdle)
1640-
if sc.srv.IdleTimeout != 0 {
1641+
if sc.srv.IdleTimeout > 0 {
16411642
sc.idleTimer.Reset(sc.srv.IdleTimeout)
16421643
}
16431644
if h1ServerKeepAlivesDisabled(sc.hs) {

0 commit comments

Comments
 (0)