From bef896a7adefd9f5b7720446ee6dd00045595598 Mon Sep 17 00:00:00 2001 From: yangbinnnn Date: Wed, 31 Oct 2018 18:13:18 +0800 Subject: [PATCH] [bugfix] Fix lastUpdate cache policy when information reporting of agent(#469) --- modules/hbs/cache/agents.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/hbs/cache/agents.go b/modules/hbs/cache/agents.go index 25d10bbf1..c44f9af19 100644 --- a/modules/hbs/cache/agents.go +++ b/modules/hbs/cache/agents.go @@ -19,10 +19,11 @@ package cache // 提供http接口查询机器信息,排查重名机器的时候比较有用 import ( - "github.com/open-falcon/falcon-plus/common/model" - "github.com/open-falcon/falcon-plus/modules/hbs/db" "sync" "time" + + "github.com/open-falcon/falcon-plus/common/model" + "github.com/open-falcon/falcon-plus/modules/hbs/db" ) type SafeAgents struct { @@ -48,10 +49,12 @@ func (this *SafeAgents) Put(req *model.AgentReportRequest) { agentInfo.ReportRequest.PluginVersion != req.PluginVersion { db.UpdateAgent(val) - this.Lock() - this.M[req.Hostname] = val - this.Unlock() } + + // 更新hbs 时间 + this.Lock() + this.M[req.Hostname] = val + this.Unlock() } func (this *SafeAgents) Get(hostname string) (*model.AgentUpdateInfo, bool) {