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()
|
queue.mu.Lock()
|
||||||
now := time.Now().Add(-time.Millisecond * 500)
|
now := time.Now().Add(-time.Millisecond * 500)
|
||||||
|
keepIndex := -1
|
||||||
for i, packet := range queue.Packets {
|
for i, packet := range queue.Packets {
|
||||||
if packet.Added.After(now) {
|
if packet.Added.After(now) {
|
||||||
stillInQueue := queue.Packets[i:]
|
keepIndex = i
|
||||||
log.Printf("DEBUG: Requeueing %d packets\n", len(stillInQueue))
|
|
||||||
queue.Packets = stillInQueue
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if keepIndex == -1 {
|
||||||
|
queue.Packets = queue.Packets[:0]
|
||||||
|
} else {
|
||||||
|
queue.Packets = queue.Packets[keepIndex:]
|
||||||
|
}
|
||||||
queue.Packets = append(queue.Packets, PacketWithData{
|
queue.Packets = append(queue.Packets, PacketWithData{
|
||||||
MessageType: messageType,
|
MessageType: messageType,
|
||||||
Added: ts,
|
Added: ts,
|
||||||
|
|||||||
Reference in New Issue
Block a user