Fix: use correctly last record

This commit is contained in:
gVisor bot 2019-09-26 10:08:50 +08:00
parent f86ab079f7
commit 462b617df7
2 changed files with 7 additions and 7 deletions

View File

@ -114,11 +114,11 @@ func (p *Proxy) LastDelay() (delay uint16) {
return max
}
head := p.history.First()
if head == nil {
last := p.history.Last()
if last == nil {
return max
}
history := head.(C.DelayHistory)
history := last.(C.DelayHistory)
if history.Delay == 0 {
return max
}

View File

@ -34,16 +34,16 @@ func (q *Queue) Pop() interface{} {
return head
}
// First returns the head of items without deleting.
func (q *Queue) First() interface{} {
// Last returns the last of item.
func (q *Queue) Last() interface{} {
if len(q.items) == 0 {
return nil
}
q.lock.RLock()
head := q.items[0]
last := q.items[len(q.items)-1]
q.lock.RUnlock()
return head
return last
}
// Copy get the copy of queue.