Преглед на файлове

[bugfix] Fix lastUpdate cache policy when information reporting of agent(#469)

yangbinnnn преди 6 години
родител
ревизия
bef896a7ad
променени са 1 файла, в които са добавени 8 реда и са изтрити 5 реда
  1. 8 5
      modules/hbs/cache/agents.go

+ 8 - 5
modules/hbs/cache/agents.go

@@ -19,10 +19,11 @@ package cache
 // 提供http接口查询机器信息,排查重名机器的时候比较有用
 // 提供http接口查询机器信息,排查重名机器的时候比较有用
 
 
 import (
 import (
-	"github.com/open-falcon/falcon-plus/common/model"
-	"github.com/open-falcon/falcon-plus/modules/hbs/db"
 	"sync"
 	"sync"
 	"time"
 	"time"
+
+	"github.com/open-falcon/falcon-plus/common/model"
+	"github.com/open-falcon/falcon-plus/modules/hbs/db"
 )
 )
 
 
 type SafeAgents struct {
 type SafeAgents struct {
@@ -48,10 +49,12 @@ func (this *SafeAgents) Put(req *model.AgentReportRequest) {
 		agentInfo.ReportRequest.PluginVersion != req.PluginVersion {
 		agentInfo.ReportRequest.PluginVersion != req.PluginVersion {
 
 
 		db.UpdateAgent(val)
 		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) {
 func (this *SafeAgents) Get(hostname string) (*model.AgentUpdateInfo, bool) {