transport: fix race causing flow control discrepancy when sending messages over server limit (#1859)

* In case of an error write transport quota back.

* Added test.
This commit is contained in:
mmukhi
2018-02-13 11:17:19 -08:00
committed by GitHub
parent 6c48c7f5c8
commit 484b3ebb4a
3 changed files with 48 additions and 0 deletions

View File

@ -888,6 +888,8 @@ func (t *http2Server) Write(s *Stream, hdr []byte, data []byte, opts *Options) e
}
ltq, _, err := t.localSendQuota.get(size, s.waiters)
if err != nil {
// Add the acquired quota back to transport.
t.sendQuotaPool.add(tq)
return err
}
// even if ltq is smaller than size we don't adjust size since,