mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-17 02:47:51 +01:00
UDT bug: Fix #68 fillDataToMTU, appended slice was not returned.
This commit is contained in:
@@ -148,7 +148,7 @@ func (s *udtSocketSend) goSendEvent() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
s.fillDataToMTU(msg.content, messageOut) // a trick to fill up the packet immediately with data (stream only)
|
msg.content = s.fillDataToMTU(msg.content, messageOut) // a trick to fill up the packet immediately with data (stream only)
|
||||||
|
|
||||||
s.processDataMsg(msg.content, msg.tim, msg.ttl, true)
|
s.processDataMsg(msg.content, msg.tim, msg.ttl, true)
|
||||||
|
|
||||||
@@ -198,9 +198,9 @@ func (s *udtSocketSend) reevalSendState() sendState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fillDataToMTU tries to fill up data until MTU is reached if data is immediately available in the channel. Only for streaming socket.
|
// fillDataToMTU tries to fill up data until MTU is reached if data is immediately available in the channel. Only for streaming socket.
|
||||||
func (s *udtSocketSend) fillDataToMTU(data []byte, dataChan <-chan sendMessage) {
|
func (s *udtSocketSend) fillDataToMTU(data []byte, dataChan <-chan sendMessage) (dataFilled []byte) {
|
||||||
if s.socket.isDatagram {
|
if s.socket.isDatagram {
|
||||||
return
|
return data
|
||||||
}
|
}
|
||||||
mtu := int(s.socket.maxPacketSize) - 16 // 16 = data packet header
|
mtu := int(s.socket.maxPacketSize) - 16 // 16 = data packet header
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ func (s *udtSocketSend) fillDataToMTU(data []byte, dataChan <-chan sendMessage)
|
|||||||
select {
|
select {
|
||||||
case morePartialSend := <-dataChan:
|
case morePartialSend := <-dataChan:
|
||||||
if len(morePartialSend.content) == 0 { // Indicates EOF.
|
if len(morePartialSend.content) == 0 { // Indicates EOF.
|
||||||
return
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
// we have more data, concat and try again
|
// we have more data, concat and try again
|
||||||
@@ -217,9 +217,10 @@ func (s *udtSocketSend) fillDataToMTU(data []byte, dataChan <-chan sendMessage)
|
|||||||
continue
|
continue
|
||||||
default:
|
default:
|
||||||
// nothing immediately available, just send what we have
|
// nothing immediately available, just send what we have
|
||||||
return
|
return data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to pack a new data packet and send it
|
// try to pack a new data packet and send it
|
||||||
|
|||||||
Reference in New Issue
Block a user