Skip to content

Commit

Permalink
http2: only set up deadline when Server.IdleTimeout is positive
Browse files Browse the repository at this point in the history
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
  • Loading branch information
panjf2000 authored and gopherbot committed Mar 20, 2024
1 parent 89f602b commit d73acff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions http2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ type Server struct {
// IdleTimeout specifies how long until idle clients should be
// closed with a GOAWAY frame. PING frames are not considered
// activity for the purposes of IdleTimeout.
// If zero or negative, there is no timeout.
IdleTimeout time.Duration

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

if sc.srv.IdleTimeout != 0 {
if sc.srv.IdleTimeout > 0 {
sc.idleTimer = time.AfterFunc(sc.srv.IdleTimeout, sc.onIdleTimer)
defer sc.idleTimer.Stop()
}
Expand Down Expand Up @@ -1637,7 +1638,7 @@ func (sc *serverConn) closeStream(st *stream, err error) {
delete(sc.streams, st.id)
if len(sc.streams) == 0 {
sc.setConnState(http.StateIdle)
if sc.srv.IdleTimeout != 0 {
if sc.srv.IdleTimeout > 0 {
sc.idleTimer.Reset(sc.srv.IdleTimeout)
}
if h1ServerKeepAlivesDisabled(sc.hs) {
Expand Down

0 comments on commit d73acff

Please sign in to comment.