chore: decrease direct udp read memory used for no-windows platform

This commit is contained in:
wwqgtxx
2023-05-11 13:47:51 +08:00
parent d9fa051dd8
commit 75cd72385a
8 changed files with 178 additions and 17 deletions

View File

@ -186,6 +186,16 @@ func (ut *udpTracker) ReadFrom(b []byte) (int, net.Addr, error) {
return n, addr, err
}
func (ut *udpTracker) WaitReadFrom() (data []byte, put func(), addr net.Addr, err error) {
data, put, addr, err = ut.PacketConn.WaitReadFrom()
download := int64(len(data))
if ut.pushToManager {
ut.manager.PushDownloaded(download)
}
ut.DownloadTotal.Add(download)
return
}
func (ut *udpTracker) WriteTo(b []byte, addr net.Addr) (int, error) {
n, err := ut.PacketConn.WriteTo(b, addr)
upload := int64(n)