From 491970639ddea01f58ff6dc9812507c111eca5c0 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Tue, 13 Jan 2015 18:06:32 -0800 Subject: [PATCH] fix & log ping/pong; fixes #10 --- p2p/connection.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/p2p/connection.go b/p2p/connection.go index 6606eff4..e48e0066 100644 --- a/p2p/connection.go +++ b/p2p/connection.go @@ -11,9 +11,9 @@ import ( "time" flow "code.google.com/p/mxk/go1/flowcontrol" + "github.com/tendermint/log15" . "github.com/tendermint/tendermint/binary" . "github.com/tendermint/tendermint/common" - "github.com/tendermint/log15" ) const ( @@ -261,11 +261,13 @@ FOR_LOOP: channel.updateStats() } case <-c.pingTimer.Ch: + log.Debug("Send Ping") WriteByte(packetTypePing, c.bufWriter, &n, &err) c.sendMonitor.Update(int(n)) c.flush() case <-c.pong: - WriteByte(packetTypePing, c.bufWriter, &n, &err) + log.Debug("Send Pong") + WriteByte(packetTypePong, c.bufWriter, &n, &err) c.sendMonitor.Update(int(n)) c.flush() case <-c.quit: @@ -363,7 +365,7 @@ FOR_LOOP: // Peek into bufReader for debugging if numBytes := c.bufReader.Buffered(); numBytes > 0 { - log.Debug("Peek connection buffer", "bytes", log15.Lazy{func() []byte { + log.Debug("Peek connection buffer", "numBytes", numBytes, "bytes", log15.Lazy{func() []byte { bytes, err := c.bufReader.Peek(MinInt(numBytes, 100)) if err == nil { return bytes @@ -391,9 +393,11 @@ FOR_LOOP: switch pktType { case packetTypePing: // TODO: prevent abuse, as they cause flush()'s. + log.Debug("Receive Ping") c.pong <- struct{}{} case packetTypePong: // do nothing + log.Debug("Receive Pong") case packetTypeMsg: pkt, n, err := msgPacket{}, new(int64), new(error) ReadBinary(&pkt, c.bufReader, n, err)