From b8c076ca79cff881249c178d7890ad3b34e9a817 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 5 Jun 2018 14:47:00 +0400 Subject: [PATCH] do not drain the channel because there is no channel, duh Fixes https://github.com/cosmos/cosmos-sdk/issues/1045 --- p2p/conn/connection.go | 4 +--- p2p/conn/connection_test.go | 8 +++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/p2p/conn/connection.go b/p2p/conn/connection.go index 94856134b..5c7f19cf7 100644 --- a/p2p/conn/connection.go +++ b/p2p/conn/connection.go @@ -545,9 +545,7 @@ FOR_LOOP: // not goroutine-safe func (c *MConnection) stopPongTimer() { if c.pongTimer != nil { - if !c.pongTimer.Stop() { - <-c.pongTimer.C - } + _ = c.pongTimer.Stop() c.pongTimer = nil } } diff --git a/p2p/conn/connection_test.go b/p2p/conn/connection_test.go index a927d6959..ade8e8e9f 100644 --- a/p2p/conn/connection_test.go +++ b/p2p/conn/connection_test.go @@ -6,9 +6,11 @@ import ( "testing" "time" + "github.com/fortytw2/leaktest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tendermint/go-amino" + + amino "github.com/tendermint/go-amino" "github.com/tendermint/tmlibs/log" ) @@ -242,7 +244,11 @@ func TestMConnectionMultiplePings(t *testing.T) { } func TestMConnectionPingPongs(t *testing.T) { + // check that we are not leaking any go-routines + defer leaktest.CheckTimeout(t, 10*time.Second)() + server, client := net.Pipe() + defer server.Close() defer client.Close()