diff options
author | Devon Hudson <devonhudson@librem.one> | 2023-01-12 09:22:53 -0700 |
---|---|---|
committer | Devon Hudson <devonhudson@librem.one> | 2023-01-12 09:23:03 -0700 |
commit | 477a44faa67eabba0f5d7f632b12fd6bb2d7ec5b (patch) | |
tree | a96221837bf307a62387053cca0e9c1878b967ff | |
parent | 0491a8e3436bc17535a4c57d26376af83685a97c (diff) |
Always initialize statistics server map
-rw-r--r-- | federationapi/statistics/statistics.go | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/federationapi/statistics/statistics.go b/federationapi/statistics/statistics.go index 2ba99112..0a44375c 100644 --- a/federationapi/statistics/statistics.go +++ b/federationapi/statistics/statistics.go @@ -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] |