lib/connections: Try not to deadlock (fixes #2987)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/2991
This commit is contained in:
Audrius Butkevicius
2016-04-18 20:25:31 +00:00
committed by Jakob Borg
parent 893cc025f9
commit ea54525a33
2 changed files with 15 additions and 22 deletions

View File

@@ -1042,13 +1042,6 @@ func (m *Model) AddConnection(conn Connection, hello protocol.HelloMessage) {
l.Infof(`Device %s client is "%s %s" named "%s"`, deviceID, hello.ClientName, hello.ClientVersion, hello.DeviceName)
device, ok := m.cfg.Devices()[deviceID]
if ok && (device.Name == "" || m.cfg.Options().OverwriteNames) {
device.Name = hello.DeviceName
m.cfg.SetDevice(device)
m.cfg.Save()
}
conn.Start()
cm := m.generateClusterConfig(deviceID)
@@ -1062,6 +1055,13 @@ func (m *Model) AddConnection(conn Connection, hello protocol.HelloMessage) {
m.fmut.RUnlock()
m.pmut.Unlock()
device, ok := m.cfg.Devices()[deviceID]
if ok && (device.Name == "" || m.cfg.Options().OverwriteNames) {
device.Name = hello.DeviceName
m.cfg.SetDevice(device)
m.cfg.Save()
}
m.deviceWasSeen(deviceID)
}