fix concurrency rw
This commit is contained in:
parent
7b4b583837
commit
f92b448333
|
@ -373,6 +373,9 @@ func GetLatestOnlineAgentIDs(agentIds []string, lastSeconds int) (map[string]str
|
|||
},
|
||||
},
|
||||
}
|
||||
if len(agentIds) == 0 {
|
||||
queryDSL["size"] = 2000
|
||||
}
|
||||
q.RawQuery = util.MustToJSONBytes(queryDSL)
|
||||
err, result := orm.Search(event.Event{}, &q)
|
||||
if err != nil {
|
||||
|
|
|
@ -109,7 +109,9 @@ func (sm *StateManager) checkAgentStatus() {
|
|||
return
|
||||
}
|
||||
// status change to online
|
||||
sm.agentMutex.Lock()
|
||||
sm.agentIds[agentID] = model.StatusOnline
|
||||
sm.agentMutex.Unlock()
|
||||
log.Infof("status of agent [%s] changed to online", agentID)
|
||||
return
|
||||
}else{
|
||||
|
@ -119,7 +121,9 @@ func (sm *StateManager) checkAgentStatus() {
|
|||
}
|
||||
}
|
||||
// status change to offline
|
||||
sm.agentMutex.Lock()
|
||||
sm.agentIds[agentID] = model.StatusOffline
|
||||
sm.agentMutex.Unlock()
|
||||
ag, err := sm.GetAgent(agentID)
|
||||
if err != nil {
|
||||
if err != elastic.ErrNotFound {
|
||||
|
|
Loading…
Reference in New Issue