mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-03 00:21:20 +00:00
drain pongTimeoutCh and pongTimer's channel to prevent leaks
This commit is contained in:
parent
f4ff66de30
commit
ac0123d249
@ -352,7 +352,10 @@ FOR_LOOP:
|
|||||||
c.flush()
|
c.flush()
|
||||||
case <-c.quit:
|
case <-c.quit:
|
||||||
if c.pongTimer != nil {
|
if c.pongTimer != nil {
|
||||||
_ = c.pongTimer.Stop()
|
if !c.pongTimer.Stop() {
|
||||||
|
<-c.pongTimer.C
|
||||||
|
}
|
||||||
|
drain(c.pongTimeoutCh)
|
||||||
}
|
}
|
||||||
break FOR_LOOP
|
break FOR_LOOP
|
||||||
case <-c.send:
|
case <-c.send:
|
||||||
@ -488,7 +491,10 @@ FOR_LOOP:
|
|||||||
case packetTypePong:
|
case packetTypePong:
|
||||||
c.Logger.Debug("Receive Pong")
|
c.Logger.Debug("Receive Pong")
|
||||||
if c.pongTimer != nil {
|
if c.pongTimer != nil {
|
||||||
_ = c.pongTimer.Stop()
|
if !c.pongTimer.Stop() {
|
||||||
|
<-c.pongTimer.C
|
||||||
|
}
|
||||||
|
drain(c.pongTimeoutCh)
|
||||||
}
|
}
|
||||||
case packetTypeMsg:
|
case packetTypeMsg:
|
||||||
pkt, n, err := msgPacket{}, int(0), error(nil)
|
pkt, n, err := msgPacket{}, int(0), error(nil)
|
||||||
@ -764,3 +770,13 @@ 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 struct{}) {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ch:
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user