Skip to content

Commit

Permalink
Improve (ncpio/mqttdpinger): net.Conn SetReadDeadline 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo authored and Leo committed Nov 3, 2021
1 parent 3c4c7f3 commit 790ec05
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ncpio/mqttdpinger.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func NewPingHandler(client *paho.Client, topic string) *PingHandler {
// the required interface function()
func (p *PingHandler) Start(c net.Conn, pt time.Duration) {
p.mu.Lock()
p.sendCount = 0
p.recvCount = 0
p.conn = c
p.stop = make(chan struct{})
p.mu.Unlock()
Expand Down Expand Up @@ -78,6 +80,9 @@ func (p *PingHandler) Start(c net.Conn, pt time.Duration) {
atomic.AddInt32(&p.pingOutstanding, 1)
p.lastPing = time.Now()
p.sendCount++
if p.sendCount - p.recvCount > 3 {
return
}
p.debug.Println("pingHandler sending ping request")
}
}
Expand Down

0 comments on commit 790ec05

Please sign in to comment.