Data race: deviceActivity methods with value receiver :(

This commit is contained in:
Jakob Borg 2014-11-29 22:22:50 +01:00
parent 4fdecc9b85
commit a918aa97d9

View File

@ -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()
var low int = 2<<30 - 1
var selected protocol.DeviceID
@ -49,14 +49,14 @@ func (m deviceActivity) leastBusy(availability []protocol.DeviceID) protocol.Dev
return selected
}
func (m deviceActivity) using(device protocol.DeviceID) {
func (m *deviceActivity) using(device protocol.DeviceID) {
m.mut.Lock()
defer m.mut.Unlock()
m.act[device]++
m.mut.Unlock()
}
func (m deviceActivity) done(device protocol.DeviceID) {
func (m *deviceActivity) done(device protocol.DeviceID) {
m.mut.Lock()
defer m.mut.Unlock()
m.act[device]--
m.mut.Unlock()
}