From 904c354ee4c45a25849e7b821f0ae2ff83cf76a0 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Thu, 26 Sep 2019 10:08:50 +0800 Subject: [PATCH] Fix: use correctly last record --- adapters/outbound/base.go | 6 +++--- common/queue/queue.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/adapters/outbound/base.go b/adapters/outbound/base.go index 710afad..b560fc7 100644 --- a/adapters/outbound/base.go +++ b/adapters/outbound/base.go @@ -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 } diff --git a/common/queue/queue.go b/common/queue/queue.go index 7cb51b8..f1a0c6f 100644 --- a/common/queue/queue.go +++ b/common/queue/queue.go @@ -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.