fix a possible race condition

This commit is contained in:
xtaci
2019-12-19 16:18:34 +08:00
parent 36273058e1
commit 3b54c0fc00
+1 -1
View File
@@ -103,8 +103,8 @@ func (s *Stream) WriteTo(w io.Writer) (n int64, err error) {
if buf != nil {
nw, ew := w.Write(buf)
defaultAllocator.Put(buf)
s.sess.returnTokens(len(buf))
defaultAllocator.Put(buf)
if nw > 0 {
n += int64(nw)
}