mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-08 18:16:59 +00:00
Always initialize statistics server map
This commit is contained in:
parent
0491a8e343
commit
477a44faa6
@ -35,18 +35,13 @@ func NewStatistics(db storage.Database, failuresUntilBlacklist uint32) Statistic
|
||||
DB: db,
|
||||
FailuresUntilBlacklist: failuresUntilBlacklist,
|
||||
backoffTimers: make(map[gomatrixserverlib.ServerName]*time.Timer),
|
||||
servers: make(map[gomatrixserverlib.ServerName]*ServerStatistics),
|
||||
}
|
||||
}
|
||||
|
||||
// ForServer returns server statistics for the given server name. If it
|
||||
// does not exist, it will create empty statistics and return those.
|
||||
func (s *Statistics) ForServer(serverName gomatrixserverlib.ServerName) *ServerStatistics {
|
||||
// If the map hasn't been initialised yet then do that.
|
||||
if s.servers == nil {
|
||||
s.mutex.Lock()
|
||||
s.servers = make(map[gomatrixserverlib.ServerName]*ServerStatistics)
|
||||
s.mutex.Unlock()
|
||||
}
|
||||
// Look up if we have statistics for this server already.
|
||||
s.mutex.RLock()
|
||||
server, found := s.servers[serverName]
|
||||
|
Loading…
Reference in New Issue
Block a user