UDT: Fix critical bugs: Virtual Connection should not block.

Revert close channel from last commit.
This commit is contained in:
Kleissner
2022-02-27 04:11:59 +01:00
parent 71cd90274c
commit c9158cb15f
2 changed files with 6 additions and 6 deletions

View File

@@ -44,7 +44,7 @@ func newVirtualPacketConn(peer *PeerInfo, sendData func(data []byte, sequenceNum
v = &virtualPacketConn{
peer: peer,
sendData: sendData,
incomingData: make(chan []byte, 100),
incomingData: make(chan []byte, 512),
outgoingData: make(chan []byte),
terminationSignal: make(chan struct{}),
}
@@ -67,7 +67,7 @@ func (v *virtualPacketConn) writeForward() {
}
}
// receiveData receives incoming data via an external message. Blocking until a read occurs or the connection is terminated!
// receiveData receives incoming data via an external message. Non-blocking.
func (v *virtualPacketConn) receiveData(data []byte) {
if v.IsTerminated() {
return
@@ -77,8 +77,9 @@ func (v *virtualPacketConn) receiveData(data []byte) {
select {
case v.incomingData <- data:
case <-v.terminationSignal:
default:
// packet lost
}
// TODO: Add read timeout
}
// Terminate closes the connection. Do not call this function manually. Use the underlying protocol's function to close the connection.