浏览代码

http2: fix minor stream accounting bug

Update golang/go#18083

Change-Id: I2600f8a7a0d3a630003c010496a7fceca1b9f660
Reviewed-on: https://go-review.googlesource.com/33974
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Tom Bergan 9 年之前
父节点
当前提交
0c96df335e
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      http2/server.go

+ 7 - 2
http2/server.go

@@ -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
@@ -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
 		}
 	}
@@ -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)
 	}