lib/model: Reduce fmut locking in ClusterConfig (#6913)
The FileSet.Drop operation in there needs to potentially update a whole lot of global lists, which can take a while (longer than the deadlock interval apparently)
This commit is contained in:
+4
-2
@@ -1022,7 +1022,6 @@ func (m *model) ClusterConfig(deviceID protocol.DeviceID, cm protocol.ClusterCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m.fmut.RLock()
|
|
||||||
var paused []string
|
var paused []string
|
||||||
for _, folder := range cm.Folders {
|
for _, folder := range cm.Folders {
|
||||||
cfg, ok := m.cfg.Folder(folder.ID)
|
cfg, ok := m.cfg.Folder(folder.ID)
|
||||||
@@ -1048,7 +1047,9 @@ func (m *model) ClusterConfig(deviceID protocol.DeviceID, cm protocol.ClusterCon
|
|||||||
if cfg.Paused {
|
if cfg.Paused {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
m.fmut.RLock()
|
||||||
fs, ok := m.folderFiles[folder.ID]
|
fs, ok := m.folderFiles[folder.ID]
|
||||||
|
m.fmut.RUnlock()
|
||||||
if !ok {
|
if !ok {
|
||||||
// Shouldn't happen because !cfg.Paused, but might happen
|
// Shouldn't happen because !cfg.Paused, but might happen
|
||||||
// if the folder is about to be unpaused, but not yet.
|
// if the folder is about to be unpaused, but not yet.
|
||||||
@@ -1122,9 +1123,11 @@ func (m *model) ClusterConfig(deviceID protocol.DeviceID, cm protocol.ClusterCon
|
|||||||
// likely use delta indexes. We might already have files
|
// likely use delta indexes. We might already have files
|
||||||
// that we need to pull so let the folder runner know
|
// that we need to pull so let the folder runner know
|
||||||
// that it should recheck the index data.
|
// that it should recheck the index data.
|
||||||
|
m.fmut.RLock()
|
||||||
if runner := m.folderRunners[folder.ID]; runner != nil {
|
if runner := m.folderRunners[folder.ID]; runner != nil {
|
||||||
defer runner.SchedulePull()
|
defer runner.SchedulePull()
|
||||||
}
|
}
|
||||||
|
m.fmut.RUnlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1143,7 +1146,6 @@ func (m *model) ClusterConfig(deviceID protocol.DeviceID, cm protocol.ClusterCon
|
|||||||
// implementing suture.IsCompletable).
|
// implementing suture.IsCompletable).
|
||||||
m.Add(is)
|
m.Add(is)
|
||||||
}
|
}
|
||||||
m.fmut.RUnlock()
|
|
||||||
|
|
||||||
m.pmut.Lock()
|
m.pmut.Lock()
|
||||||
m.remotePausedFolders[deviceID] = paused
|
m.remotePausedFolders[deviceID] = paused
|
||||||
|
|||||||
Reference in New Issue
Block a user