4
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2025-07-09 14:34:06 +00:00

eliminate some more copying between slices

This commit is contained in:
Arceliar
2019-08-04 14:50:19 -05:00
parent f52955ee0f
commit 75b931f37e
2 changed files with 13 additions and 8 deletions

View File

@ -54,13 +54,13 @@ func (s *tunConn) reader() (err error) {
s.tun.log.Debugln("Starting conn reader for", s.conn.String())
defer s.tun.log.Debugln("Stopping conn reader for", s.conn.String())
var n int
b := make([]byte, 65535)
for {
select {
case <-s.stop:
return nil
default:
}
b := util.ResizeBytes(util.GetBytes(), 65535)
if n, err = s.conn.Read(b); err != nil {
if e, eok := err.(yggdrasil.ConnError); eok && !e.Temporary() {
if e.Closed() {
@ -71,9 +71,10 @@ func (s *tunConn) reader() (err error) {
return e
}
} else if n > 0 {
bs := append(util.GetBytes(), b[:n]...)
s.tun.send <- bs
s.tun.send <- b[:n]
s.stillAlive()
} else {
util.PutBytes(b)
}
}
}