lib/model: Add pmut locking for DeviceStatistics (fixes #9274)

Looking at deviceConnIDs requires this. Added in #9256.
This commit is contained in:
Jakob Borg 2023-12-11 08:02:25 +01:00
parent 3850a08252
commit 48883e0e32

View File

@ -812,6 +812,8 @@ func (m *model) ConnectionStats() map[string]interface{} {
func (m *model) DeviceStatistics() (map[protocol.DeviceID]stats.DeviceStatistics, error) { func (m *model) DeviceStatistics() (map[protocol.DeviceID]stats.DeviceStatistics, error) {
m.fmut.RLock() m.fmut.RLock()
defer m.fmut.RUnlock() defer m.fmut.RUnlock()
m.pmut.RLock()
defer m.pmut.RUnlock()
res := make(map[protocol.DeviceID]stats.DeviceStatistics, len(m.deviceStatRefs)) res := make(map[protocol.DeviceID]stats.DeviceStatistics, len(m.deviceStatRefs))
for id, sr := range m.deviceStatRefs { for id, sr := range m.deviceStatRefs {
stats, err := sr.GetStatistics() stats, err := sr.GetStatistics()