MCPcopy Index your code
hub / github.com/syncthing/syncthing / pingReceiver

Method pingReceiver

lib/protocol/protocol.go:1028–1047  ·  view source on GitHub ↗

The pingReceiver checks that we've received a message (any message will do, but we expect pings in the absence of other messages) within the last ReceiveTimeout. If not, we close the connection with an ErrTimeout.

()

Source from the content-addressed store, hash-verified

1026// but we expect pings in the absence of other messages) within the last
1027// ReceiveTimeout. If not, we close the connection with an ErrTimeout.
1028func (c *rawConnection) pingReceiver() {
1029 ticker := time.NewTicker(ReceiveTimeout / 2)
1030 defer ticker.Stop()
1031
1032 for {
1033 select {
1034 case <-ticker.C:
1035 d := time.Since(c.cr.Last())
1036 if d > ReceiveTimeout {
1037 l.Debugln(c.deviceID, "ping timeout", d)
1038 c.internalClose(ErrTimeout)
1039 }
1040
1041 l.Debugln(c.deviceID, "last read within", d)
1042
1043 case <-c.closed:
1044 return
1045 }
1046 }
1047}
1048
1049type Statistics struct {
1050 At time.Time `json:"at"`

Callers 1

StartMethod · 0.95

Calls 5

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

Tested by

no test coverage detected