Skip to content

Commit

Permalink
http2: fix minor stream accounting bug
Browse files Browse the repository at this point in the history
Update golang/go#18083

Change-Id: I2600f8a7a0d3a630003c010496a7fceca1b9f660
Reviewed-on: https://go-review.googlesource.com/33974
Reviewed-by: Brad Fitzpatrick <[email protected]>
Run-TryBot: Brad Fitzpatrick <[email protected]>
  • Loading branch information
tombergan authored and bradfitz committed Dec 6, 2016
1 parent 4a1c855 commit 0c96df3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions http2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ func (sc *serverConn) maxHeaderListSize() uint32 {
return uint32(n + typicalHeaders*perFieldOverhead)
}

func (sc *serverConn) curOpenStreams() uint32 {
sc.serveG.check()
return sc.curClientStreams + sc.curPushedStreams
}

// stream represents a stream. This is the minimal metadata needed by
// the serve goroutine. Most of the actual stream state is owned by
// the http.Handler's goroutine in the responseWriter. Because the
Expand Down Expand Up @@ -753,7 +758,7 @@ func (sc *serverConn) serve() {
fn(loopNum)
}

if sc.inGoAway && sc.curClientStreams == 0 && !sc.needToSendGoAway && !sc.writingFrame {
if sc.inGoAway && sc.curOpenStreams() == 0 && !sc.needToSendGoAway && !sc.writingFrame {
return
}
}
Expand Down Expand Up @@ -1681,7 +1686,7 @@ func (sc *serverConn) newStream(id, pusherID uint32, state streamState) *stream
} else {
sc.curClientStreams++
}
if sc.curClientStreams+sc.curPushedStreams == 1 {
if sc.curOpenStreams() == 1 {
sc.setConnState(http.StateActive)
}

Expand Down

0 comments on commit 0c96df3

Please sign in to comment.