MCPcopy
hub / github.com/syncthing/syncthing / Start

Method Start

lib/protocol/protocol.go:272–311  ·  view source on GitHub ↗

Start creates the goroutines for sending and receiving of messages. It must be called once after creating a connection. It should only be called once, subsequent calls will have no effect.

()

Source from the content-addressed store, hash-verified

270// be called once after creating a connection. It should only be called once,
271// subsequent calls will have no effect.
272func (c *rawConnection) Start() {
273 c.startStopMut.Lock()
274 defer c.startStopMut.Unlock()
275
276 select {
277 case <-c.started:
278 return
279 case <-c.closed:
280 // we have already closed the connection before starting processing
281 // on it.
282 return
283 default:
284 }
285
286 c.loopWG.Add(5)
287 go func() {
288 c.readerLoop()
289 c.loopWG.Done()
290 }()
291 go func() {
292 err := c.dispatcherLoop()
293 c.Close(err)
294 c.loopWG.Done()
295 }()
296 go func() {
297 c.writerLoop()
298 c.loopWG.Done()
299 }()
300 go func() {
301 c.pingSender()
302 c.loopWG.Done()
303 }()
304 go func() {
305 c.pingReceiver()
306 c.loopWG.Done()
307 }()
308
309 c.startTime = time.Now().Truncate(time.Second)
310 close(c.started)
311}
312
313func (c *rawConnection) DeviceID() DeviceID {
314 return c.deviceID

Callers

nothing calls this directly

Calls 11

readerLoopMethod · 0.95
dispatcherLoopMethod · 0.95
CloseMethod · 0.95
writerLoopMethod · 0.95
pingSenderMethod · 0.95
pingReceiverMethod · 0.95
UnlockMethod · 0.80
DoneMethod · 0.80
TruncateMethod · 0.65
NowMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected