Make sure connection is added to m.protoConn and m.rawConn before it's Start()ed (fixes #2034)

This commit is contained in:
Jakob Borg
2015-07-10 16:37:57 +10:00
parent 5bb8ea7449
commit 0c28216ee5
6 changed files with 27 additions and 3 deletions

View File

@@ -89,6 +89,7 @@ type Model interface {
}
type Connection interface {
Start()
ID() DeviceID
Name() string
Index(folder string, files []FileInfo, flags uint32, options []Option) error
@@ -161,12 +162,16 @@ func NewConnection(deviceID DeviceID, reader io.Reader, writer io.Writer, receiv
compression: compress,
}
return wireFormatConnection{&c}
}
// Start creates the goroutines for sending a receiving of messages. It must
// be called exactly once after creating a connection.
func (c *rawConnection) Start() {
go c.readerLoop()
go c.writerLoop()
go c.pingerLoop()
go c.idGenerator()
return wireFormatConnection{&c}
}
func (c *rawConnection) ID() DeviceID {