mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-22 22:58:25 +00:00
Data race: Discoverer.registryLock must cover the contents of registry as well
This commit is contained in:
parent
07cdf0364c
commit
577aaf8ad6
@ -340,9 +340,10 @@ func (d *Discoverer) registerDevice(addr net.Addr, device Device) bool {
|
|||||||
var id protocol.DeviceID
|
var id protocol.DeviceID
|
||||||
copy(id[:], device.ID)
|
copy(id[:], device.ID)
|
||||||
|
|
||||||
d.registryLock.RLock()
|
d.registryLock.Lock()
|
||||||
|
defer d.registryLock.Unlock()
|
||||||
|
|
||||||
current := d.filterCached(d.registry[id])
|
current := d.filterCached(d.registry[id])
|
||||||
d.registryLock.RUnlock()
|
|
||||||
|
|
||||||
orig := current
|
orig := current
|
||||||
|
|
||||||
@ -372,9 +373,7 @@ func (d *Discoverer) registerDevice(addr net.Addr, device Device) bool {
|
|||||||
l.Debugf("discover: register: %v -> %v", id, current)
|
l.Debugf("discover: register: %v -> %v", id, current)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.registryLock.Lock()
|
|
||||||
d.registry[id] = current
|
d.registry[id] = current
|
||||||
d.registryLock.Unlock()
|
|
||||||
|
|
||||||
if len(current) > len(orig) {
|
if len(current) > len(orig) {
|
||||||
addrs := make([]string, len(current))
|
addrs := make([]string, len(current))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user