Skip to content

Commit 4013f8d

Browse files
authored
tentative fix to a flow control over-give-back bug (#1170)
1 parent ffa4ec7 commit 4013f8d

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

transport/http2_client.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -802,11 +802,6 @@ func (t *http2Client) handleData(f *http2.DataFrame) {
802802
return
803803
}
804804
if size > 0 {
805-
if f.Header().Flags.Has(http2.FlagDataPadded) {
806-
if w := t.fc.onRead(uint32(size) - uint32(len(f.Data()))); w > 0 {
807-
t.controlBuf.put(&windowUpdate{0, w})
808-
}
809-
}
810805
s.mu.Lock()
811806
if s.state == streamDone {
812807
s.mu.Unlock()
@@ -825,6 +820,9 @@ func (t *http2Client) handleData(f *http2.DataFrame) {
825820
return
826821
}
827822
if f.Header().Flags.Has(http2.FlagDataPadded) {
823+
if w := t.fc.onRead(uint32(size) - uint32(len(f.Data()))); w > 0 {
824+
t.controlBuf.put(&windowUpdate{0, w})
825+
}
828826
if w := s.fc.onRead(uint32(size) - uint32(len(f.Data()))); w > 0 {
829827
t.controlBuf.put(&windowUpdate{s.id, w})
830828
}

transport/http2_server.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,6 @@ func (t *http2Server) handleData(f *http2.DataFrame) {
465465
return
466466
}
467467
if size > 0 {
468-
if f.Header().Flags.Has(http2.FlagDataPadded) {
469-
if w := t.fc.onRead(uint32(size) - uint32(len(f.Data()))); w > 0 {
470-
t.controlBuf.put(&windowUpdate{0, w})
471-
}
472-
}
473468
s.mu.Lock()
474469
if s.state == streamDone {
475470
s.mu.Unlock()
@@ -486,6 +481,9 @@ func (t *http2Server) handleData(f *http2.DataFrame) {
486481
return
487482
}
488483
if f.Header().Flags.Has(http2.FlagDataPadded) {
484+
if w := t.fc.onRead(uint32(size) - uint32(len(f.Data()))); w > 0 {
485+
t.controlBuf.put(&windowUpdate{0, w})
486+
}
489487
if w := s.fc.onRead(uint32(size) - uint32(len(f.Data()))); w > 0 {
490488
t.controlBuf.put(&windowUpdate{s.id, w})
491489
}

0 commit comments

Comments
 (0)