From aafc96f58fdb0bd0de4bbee990fded765fe38939 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Wed, 27 Jul 2016 21:36:25 +0000 Subject: [PATCH] lib/model, lib/protocol: Sequence ClusterConfig properly (fixes #3448) GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3452 --- lib/model/model.go | 5 ++++- lib/protocol/protocol.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/model/model.go b/lib/model/model.go index bc23fda3b..b36759baf 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -649,8 +649,11 @@ func (m *Model) ClusterConfig(deviceID protocol.DeviceID, cm protocol.ClusterCon tempIndexFolders := make([]string, 0, len(cm.Folders)) m.pmut.RLock() - conn := m.conn[deviceID] + conn, ok := m.conn[deviceID] m.pmut.RUnlock() + if !ok { + panic("bug: ClusterConfig called on closed or nonexistent connection") + } m.fmut.Lock() for _, folder := range cm.Folders { diff --git a/lib/protocol/protocol.go b/lib/protocol/protocol.go index cfbe06276..96493e8ef 100644 --- a/lib/protocol/protocol.go +++ b/lib/protocol/protocol.go @@ -302,7 +302,7 @@ func (c *rawConnection) readerLoop() (err error) { if state != stateInitial { return fmt.Errorf("protocol error: cluster config message in state %d", state) } - go c.receiver.ClusterConfig(c.id, *msg) + c.receiver.ClusterConfig(c.id, *msg) state = stateReady case *Index: