mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-29 06:01:21 +00:00
parent
2a24ae90c1
commit
fc585bcdec
@ -201,12 +201,12 @@ func (c *MConnection) OnStart() error {
|
|||||||
// OnStop implements BaseService
|
// OnStop implements BaseService
|
||||||
func (c *MConnection) OnStop() {
|
func (c *MConnection) OnStop() {
|
||||||
c.BaseService.OnStop()
|
c.BaseService.OnStop()
|
||||||
if c.quit != nil {
|
|
||||||
close(c.quit)
|
|
||||||
}
|
|
||||||
c.flushTimer.Stop()
|
c.flushTimer.Stop()
|
||||||
c.pingTimer.Stop()
|
c.pingTimer.Stop()
|
||||||
c.chStatsTimer.Stop()
|
c.chStatsTimer.Stop()
|
||||||
|
if c.quit != nil {
|
||||||
|
close(c.quit)
|
||||||
|
}
|
||||||
c.conn.Close() // nolint: errcheck
|
c.conn.Close() // nolint: errcheck
|
||||||
|
|
||||||
// We can't close pong safely here because
|
// We can't close pong safely here because
|
||||||
@ -339,7 +339,10 @@ FOR_LOOP:
|
|||||||
c.sendMonitor.Update(int(n))
|
c.sendMonitor.Update(int(n))
|
||||||
c.Logger.Debug("Starting pong timer", "dur", c.config.PongTimeout)
|
c.Logger.Debug("Starting pong timer", "dur", c.config.PongTimeout)
|
||||||
c.pongTimer = time.AfterFunc(c.config.PongTimeout, func() {
|
c.pongTimer = time.AfterFunc(c.config.PongTimeout, func() {
|
||||||
c.pongTimeoutCh <- true
|
select {
|
||||||
|
case c.pongTimeoutCh <- true:
|
||||||
|
default:
|
||||||
|
}
|
||||||
})
|
})
|
||||||
c.flush()
|
c.flush()
|
||||||
case timeout := <-c.pongTimeoutCh:
|
case timeout := <-c.pongTimeoutCh:
|
||||||
@ -548,7 +551,6 @@ func (c *MConnection) stopPongTimer() {
|
|||||||
if !c.pongTimer.Stop() {
|
if !c.pongTimer.Stop() {
|
||||||
<-c.pongTimer.C
|
<-c.pongTimer.C
|
||||||
}
|
}
|
||||||
drain(c.pongTimeoutCh)
|
|
||||||
c.pongTimer = nil
|
c.pongTimer = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -780,13 +782,3 @@ type msgPacket struct {
|
|||||||
func (p msgPacket) String() string {
|
func (p msgPacket) String() string {
|
||||||
return fmt.Sprintf("MsgPacket{%X:%X T:%X}", p.ChannelID, p.Bytes, p.EOF)
|
return fmt.Sprintf("MsgPacket{%X:%X T:%X}", p.ChannelID, p.Bytes, p.EOF)
|
||||||
}
|
}
|
||||||
|
|
||||||
func drain(ch <-chan bool) {
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-ch:
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user