Minor fixes

This commit is contained in:
世界 2024-03-25 01:53:37 +08:00
parent 3c842cd21e
commit f846946810
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
6 changed files with 21 additions and 6 deletions

View file

@ -400,6 +400,11 @@ func (d *udpDefragger) feed(m *udpMessage) *udpMessage {
}
item.messages = nil
return newMessage
} else {
newMessage.release()
for _, message := range item.messages {
message.releaseMessage()
}
}
item.messages = nil
return nil

View file

@ -20,11 +20,11 @@ func (c *udpPacketConn) WaitReadPacket() (buffer *buf.Buffer, destination M.Sock
if c.readWaitOptions.NeedHeadroom() {
buffer = c.readWaitOptions.NewPacketBuffer()
_, err = buffer.Write(p.data.Bytes())
p.releaseMessage()
if err != nil {
buffer.Release()
return nil, M.Socksaddr{}, err
return
}
p.releaseMessage()
c.readWaitOptions.PostReturn(buffer)
} else {
buffer = p.data

View file

@ -392,6 +392,11 @@ func (d *udpDefragger) feed(m *udpMessage) *udpMessage {
}
item.messages = nil
return newMessage
} else {
newMessage.releaseMessage()
for _, message := range item.messages {
message.releaseMessage()
}
}
item.messages = nil
return nil

View file

@ -20,11 +20,11 @@ func (c *udpPacketConn) WaitReadPacket() (buffer *buf.Buffer, destination M.Sock
if c.readWaitOptions.NeedHeadroom() {
buffer = c.readWaitOptions.NewPacketBuffer()
_, err = buffer.Write(p.data.Bytes())
p.releaseMessage()
if err != nil {
buffer.Release()
return nil, M.Socksaddr{}, err
return
}
p.releaseMessage()
c.readWaitOptions.PostReturn(buffer)
} else {
buffer = p.data

View file

@ -437,6 +437,11 @@ func (d *udpDefragger) feed(m *udpMessage) *udpMessage {
}
item.messages = nil
return newMessage
} else {
newMessage.releaseMessage()
for _, message := range item.messages {
message.releaseMessage()
}
}
item.messages = nil
return nil

View file

@ -19,12 +19,12 @@ func (c *udpPacketConn) WaitReadPacket() (buffer *buf.Buffer, destination M.Sock
destination = p.destination
if c.readWaitOptions.NeedHeadroom() {
buffer = c.readWaitOptions.NewPacketBuffer()
p.releaseMessage()
_, err = buffer.Write(p.data.Bytes())
if err != nil {
buffer.Release()
return nil, M.Socksaddr{}, err
return
}
p.releaseMessage()
c.readWaitOptions.PostReturn(buffer)
} else {
buffer = p.data