mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-09 09:50:30 +00:00
Data race: deviceActivity methods with value receiver :(
This commit is contained in:
parent
4fdecc9b85
commit
a918aa97d9
@ -35,7 +35,7 @@ func newDeviceActivity() *deviceActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m deviceActivity) leastBusy(availability []protocol.DeviceID) protocol.DeviceID {
|
func (m *deviceActivity) leastBusy(availability []protocol.DeviceID) protocol.DeviceID {
|
||||||
m.mut.Lock()
|
m.mut.Lock()
|
||||||
var low int = 2<<30 - 1
|
var low int = 2<<30 - 1
|
||||||
var selected protocol.DeviceID
|
var selected protocol.DeviceID
|
||||||
@ -49,14 +49,14 @@ func (m deviceActivity) leastBusy(availability []protocol.DeviceID) protocol.Dev
|
|||||||
return selected
|
return selected
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m deviceActivity) using(device protocol.DeviceID) {
|
func (m *deviceActivity) using(device protocol.DeviceID) {
|
||||||
m.mut.Lock()
|
m.mut.Lock()
|
||||||
defer m.mut.Unlock()
|
|
||||||
m.act[device]++
|
m.act[device]++
|
||||||
|
m.mut.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m deviceActivity) done(device protocol.DeviceID) {
|
func (m *deviceActivity) done(device protocol.DeviceID) {
|
||||||
m.mut.Lock()
|
m.mut.Lock()
|
||||||
defer m.mut.Unlock()
|
|
||||||
m.act[device]--
|
m.act[device]--
|
||||||
|
m.mut.Unlock()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user