This commit is contained in:
iamqizhao
2016-07-25 17:24:42 -07:00
parent e32c9f5d94
commit d78e09a48d

@ -752,21 +752,29 @@ func (t *http2Client) handlePing(f *http2.PingFrame) {
func (t *http2Client) handleGoAway(f *http2.GoAwayFrame) { func (t *http2Client) handleGoAway(f *http2.GoAwayFrame) {
t.mu.Lock() t.mu.Lock()
if t.state == reachable || t.state == draining {
if f.LastStreamID > 0 && (f.LastStreamID%2 != 1 || t.goAwayID < f.LastStreamID) {
id := t.goAwayID id := t.goAwayID
if t.state == reachable || t.state == draining {
if f.LastStreamID > 0 && f.LastStreamID%2 != 1 {
t.mu.Unlock()
t.notifyError(ConnectionErrorf("received illegal http2 GOAWAY frame: stream ID %d is even", id))
return
}
select {
case <-t.goAway:
// t.goAway has been closed (i.e.,multiple GoAways).
if id < f.LastStreamID {
t.mu.Unlock() t.mu.Unlock()
t.notifyError(ConnectionErrorf("received illegal http2 GOAWAY frame: previously recv GOAWAY frame with LastStramID %d, currently recv %d", id, f.LastStreamID)) t.notifyError(ConnectionErrorf("received illegal http2 GOAWAY frame: previously recv GOAWAY frame with LastStramID %d, currently recv %d", id, f.LastStreamID))
return return
} }
t.prevGoAwayID = t.goAwayID t.prevGoAwayID = id
t.goAwayID = f.LastStreamID t.goAwayID = f.LastStreamID
select { t.mu.Unlock()
case <-t.goAway: return
// t.goAway has been closed (i.e.,multiple GoAways).
default: default:
close(t.goAway)
} }
t.goAwayID = f.LastStreamID
close(t.goAway)
} }
t.mu.Unlock() t.mu.Unlock()
} }