Skip to content

Commit

Permalink
Reset ping strike counter right before sending out data. (grpc#1905)
Browse files Browse the repository at this point in the history
Eliminate race which causes a ping to be scheduled between pingStrike counter being reset and data being scheduled.
  • Loading branch information
MakMukhi authored and lyuxuan committed Apr 4, 2018
1 parent 7e581cf commit 714bb33
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions transport/http2_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,6 @@ func (t *http2Server) Write(s *Stream, hdr []byte, data []byte, opts *Options) e
// ltq is only a soft limit.
streamQuota -= size
p := r[:size]
// Reset ping strikes when sending data since this might cause
// the peer to send ping.
atomic.StoreUint32(&t.resetPingStrikes, 1)
success := func() {
ltq := ltq
t.controlBuf.put(&dataFrame{streamID: s.id, endStream: false, d: p, f: func() {
Expand Down Expand Up @@ -1020,6 +1017,9 @@ var goAwayPing = &ping{data: [8]byte{1, 6, 1, 8, 0, 3, 3, 9}}
func (t *http2Server) itemHandler(i item) error {
switch i := i.(type) {
case *dataFrame:
// Reset ping strikes when sending data since this might cause
// the peer to send ping.
atomic.StoreUint32(&t.resetPingStrikes, 1)
if err := t.framer.fr.WriteData(i.streamID, i.endStream, i.d); err != nil {
return err
}
Expand Down

0 comments on commit 714bb33

Please sign in to comment.