remove dead packages even if no new messages exist
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m53s
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m53s
This commit is contained in:
@@ -43,14 +43,18 @@ func NewPacketQueue(connection net.Conn) *PacketQueue {
|
||||
|
||||
queue.mu.Lock()
|
||||
now := time.Now().Add(-time.Millisecond * 500)
|
||||
keepIndex := -1
|
||||
for i, packet := range queue.Packets {
|
||||
if packet.Added.After(now) {
|
||||
stillInQueue := queue.Packets[i:]
|
||||
log.Printf("DEBUG: Requeueing %d packets\n", len(stillInQueue))
|
||||
queue.Packets = stillInQueue
|
||||
keepIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if keepIndex == -1 {
|
||||
queue.Packets = queue.Packets[:0]
|
||||
} else {
|
||||
queue.Packets = queue.Packets[keepIndex:]
|
||||
}
|
||||
queue.Packets = append(queue.Packets, PacketWithData{
|
||||
MessageType: messageType,
|
||||
Added: ts,
|
||||
|
||||
Reference in New Issue
Block a user