This commit is contained in:
@@ -322,11 +322,9 @@ func (c *rawConnection) Request(ctx context.Context, folder string, name string,
|
||||
}
|
||||
|
||||
// ClusterConfig sends the cluster configuration message to the peer.
|
||||
// It must be called just once (as per BEP), otherwise it will panic.
|
||||
func (c *rawConnection) ClusterConfig(config ClusterConfig) {
|
||||
select {
|
||||
case c.clusterConfigBox <- &config:
|
||||
close(c.clusterConfigBox)
|
||||
case <-c.closed:
|
||||
}
|
||||
}
|
||||
@@ -386,13 +384,12 @@ func (c *rawConnection) dispatcherLoop() (err error) {
|
||||
switch msg := msg.(type) {
|
||||
case *ClusterConfig:
|
||||
l.Debugln("read ClusterConfig message")
|
||||
if state != stateInitial {
|
||||
return fmt.Errorf("protocol error: cluster config message in state %d", state)
|
||||
if state == stateInitial {
|
||||
state = stateReady
|
||||
}
|
||||
if err := c.receiver.ClusterConfig(c.id, *msg); err != nil {
|
||||
return errors.Wrap(err, "receiver error")
|
||||
}
|
||||
state = stateReady
|
||||
|
||||
case *Index:
|
||||
l.Debugln("read Index message")
|
||||
@@ -683,6 +680,12 @@ func (c *rawConnection) writerLoop() {
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case cc := <-c.clusterConfigBox:
|
||||
err := c.writeMessage(cc)
|
||||
if err != nil {
|
||||
c.internalClose(err)
|
||||
return
|
||||
}
|
||||
case hm := <-c.outbox:
|
||||
err := c.writeMessage(hm.msg)
|
||||
if hm.done != nil {
|
||||
|
||||
Reference in New Issue
Block a user