Reset ping strike counter right before sending out data. (#1905)
Eliminate race which causes a ping to be scheduled between pingStrike counter being reset and data being scheduled.
This commit is contained in:
@ -896,9 +896,6 @@ func (t *http2Server) Write(s *Stream, hdr []byte, data []byte, opts *Options) e
|
|||||||
// ltq is only a soft limit.
|
// ltq is only a soft limit.
|
||||||
streamQuota -= size
|
streamQuota -= size
|
||||||
p := r[: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() {
|
success := func() {
|
||||||
ltq := ltq
|
ltq := ltq
|
||||||
t.controlBuf.put(&dataFrame{streamID: s.id, endStream: false, d: p, f: func() {
|
t.controlBuf.put(&dataFrame{streamID: s.id, endStream: false, d: p, f: func() {
|
||||||
@ -1013,6 +1010,9 @@ var goAwayPing = &ping{data: [8]byte{1, 6, 1, 8, 0, 3, 3, 9}}
|
|||||||
func (t *http2Server) itemHandler(i item) error {
|
func (t *http2Server) itemHandler(i item) error {
|
||||||
switch i := i.(type) {
|
switch i := i.(type) {
|
||||||
case *dataFrame:
|
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 {
|
if err := t.framer.fr.WriteData(i.streamID, i.endStream, i.d); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user