u35s / rudp

rudp 是在UDP上实现的可靠传输(rudp is a reliable transmission on UDP)
176 stars 36 forks source link

There are something wrongs when no sendQueue message #5

Closed yuancpfive closed 3 years ago

yuancpfive commented 3 years ago
func (r *Rudp) sendMessage(tmp *packageBuffer) {
    m := r.sendQueue.head
    for m != nil {
        tmp.packMessage(m)
        m = m.next
    }

        // ***  this is not correct when some situation
    if r.sendQueue.head != nil {
        if r.sendHistory.tail == nil {
            r.sendHistory = r.sendQueue
        } else {
            r.sendHistory.tail.next = r.sendQueue.head
            r.sendHistory.tail = r.sendQueue.tail
        }
        r.sendQueue.head = nil
        r.sendQueue.tail = nil
    }
}

if sendQueue is empty , and the program will never send sendHistory's message or sendHistory's message will be sent when sendQueue contain message.