Improve: pool buffer alloc

This commit is contained in:
Dreamacro
2020-04-25 00:30:40 +08:00
parent 2b33bfae6b
commit 0e56c195bb
12 changed files with 158 additions and 48 deletions

View File

@ -34,10 +34,10 @@ func NewRedirUDPProxy(addr string) (*RedirUDPListener, error) {
go func() {
oob := make([]byte, 1024)
for {
buf := pool.BufPool.Get().([]byte)
buf := pool.Get(pool.RelayBufferSize)
n, oobn, _, lAddr, err := c.ReadMsgUDP(buf, oob)
if err != nil {
pool.BufPool.Put(buf[:cap(buf)])
pool.Put(buf)
if rl.closed {
break
}