浏览代码

chore(protocol): don't start connection routines a second time (#10146)

Simon Frei 4 月之前
父节点
当前提交
4fb8ee6a6f
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      lib/protocol/protocol.go

+ 4 - 1
lib/protocol/protocol.go

@@ -265,12 +265,15 @@ func newRawConnection(deviceID DeviceID, reader io.Reader, writer io.Writer, clo
 }
 
 // Start creates the goroutines for sending and receiving of messages. It must
-// be called exactly once after creating a connection.
+// be called once after creating a connection. It should only be called once,
+// subsequent calls will have no effect.
 func (c *rawConnection) Start() {
 	c.startStopMut.Lock()
 	defer c.startStopMut.Unlock()
 
 	select {
+	case <-c.started:
+		return
 	case <-c.closed:
 		// we have already closed the connection before starting processing
 		// on it.