Fix fragUDPMessage

This commit is contained in:
世界 2024-04-08 11:03:25 +08:00
parent 97a8f2ab1c
commit 01f8ce81ac
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 6 additions and 6 deletions

View file

@ -88,12 +88,12 @@ func (m *udpMessage) headerSize() int {
}
func fragUDPMessage(message *udpMessage, maxPacketSize int) []*udpMessage {
if message.data.Len() <= maxPacketSize {
udpMTU := maxPacketSize - message.headerSize()
if message.data.Len() <= udpMTU {
return []*udpMessage{message}
}
var fragments []*udpMessage
originPacket := message.data.Bytes()
udpMTU := maxPacketSize - message.headerSize()
for remaining := len(originPacket); remaining > 0; remaining -= udpMTU {
fragment := allocMessage()
*fragment = *message

View file

@ -84,12 +84,12 @@ func (m *udpMessage) headerSize() int {
}
func fragUDPMessage(message *udpMessage, maxPacketSize int) []*udpMessage {
if message.data.Len() <= maxPacketSize {
udpMTU := maxPacketSize - message.headerSize()
if message.data.Len() <= udpMTU {
return []*udpMessage{message}
}
var fragments []*udpMessage
originPacket := message.data.Bytes()
udpMTU := maxPacketSize - message.headerSize()
for remaining := len(originPacket); remaining > 0; remaining -= udpMTU {
fragment := allocMessage()
*fragment = *message

View file

@ -86,12 +86,12 @@ func (m *udpMessage) headerSize() int {
}
func fragUDPMessage(message *udpMessage, maxPacketSize int) []*udpMessage {
if message.data.Len() <= maxPacketSize {
udpMTU := maxPacketSize - message.headerSize()
if message.data.Len() <= udpMTU {
return []*udpMessage{message}
}
var fragments []*udpMessage
originPacket := message.data.Bytes()
udpMTU := maxPacketSize - message.headerSize()
for remaining := len(originPacket); remaining > 0; remaining -= udpMTU {
fragment := allocMessage()
*fragment = *message