MCPcopy
hub / github.com/syncthing/syncthing / pingSender

Method pingSender

lib/protocol/protocol.go:1003–1023  ·  view source on GitHub ↗

The pingSender makes sure that we've sent a message within the last PingSendInterval. If we already have something sent in the last PingSendInterval/2, we do nothing. Otherwise we send a ping message. This results in an effecting ping interval of somewhere between PingSendInterval/2 and PingSendInte

()

Source from the content-addressed store, hash-verified

1001// results in an effecting ping interval of somewhere between
1002// PingSendInterval/2 and PingSendInterval.
1003func (c *rawConnection) pingSender() {
1004 ticker := time.NewTicker(PingSendInterval / 2)
1005 defer ticker.Stop()
1006
1007 for {
1008 select {
1009 case <-ticker.C:
1010 d := time.Since(c.cw.Last())
1011 if d < PingSendInterval/2 {
1012 l.Debugln(c.deviceID, "ping skipped after wr", d)
1013 continue
1014 }
1015
1016 l.Debugln(c.deviceID, "ping -> after", d)
1017 c.ping()
1018
1019 case <-c.closed:
1020 return
1021 }
1022 }
1023}
1024
1025// The pingReceiver checks that we've received a message (any message will do,
1026// but we expect pings in the absence of other messages) within the last

Callers 1

StartMethod · 0.95

Calls 5

pingMethod · 0.95
DebuglnMethod · 0.80
SinceMethod · 0.65
StopMethod · 0.45
LastMethod · 0.45

Tested by

no test coverage detected