Commit c8a1ba96 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Discard data in splice pair when returning to pool.

parent ec46e594
package splice
import (
"io"
"sync"
)
......@@ -62,10 +63,21 @@ func (me *pairPool) get() (p *Pair, err error) {
return newSplicePair()
}
func DiscardAll(r io.Reader) {
buf := make([]byte, 32*1024)
for {
n, _ := r.Read(buf)
if n < len(buf) {
break
}
}
}
func (me *pairPool) done(p *Pair) {
me.Lock()
defer me.Unlock()
DiscardAll(p.r)
me.usedCount--
me.unused = append(me.unused, p)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment