aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Frei <freisim93@gmail.com>2023-11-19 20:55:40 +0100
committerSimon Frei <freisim93@gmail.com>2023-11-19 20:57:02 +0100
commit75d56846dc57d3f2d721fd0c7312fbfea81fb2ca (patch)
treea9e62738b90dbee790e273f4519286d425899c2a
parent13d9317a386d172960dc9e2f39709d85bdfb22e1 (diff)
downloadsyncthing-model/fmut-indexhandler.tar.gz
syncthing-model/fmut-indexhandler.zip
lib/model: Acquire fmut lock in ensureIndexHandler (fixes #9234)model/fmut-indexhandler
Towards the end of the function f.folderCfgs and f.folderRunners are read without the lock.
-rw-r--r--lib/model/model.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/model/model.go b/lib/model/model.go
index c8007f61d..64475468d 100644
--- a/lib/model/model.go
+++ b/lib/model/model.go
@@ -1346,6 +1346,9 @@ func (m *model) ensureIndexHandler(conn protocol.Connection) *indexHandlerRegist
deviceID := conn.DeviceID()
connID := conn.ConnectionID()
+ // We must acquire fmut first when acquiring both locks.
+ m.fmut.RLock()
+ defer m.fmut.RUnlock()
m.pmut.Lock()
defer m.pmut.Unlock()