Browse Source

remove some debugs

pull/983/head
Ethan Buchman 7 years ago
parent
commit
cb3ac6987e
5 changed files with 2 additions and 42 deletions
  1. +0
    -5
      consensus/reactor.go
  2. +0
    -4
      consensus/state.go
  3. +0
    -24
      p2p/connection.go
  4. +0
    -2
      p2p/peer.go
  5. +2
    -7
      p2p/switch.go

+ 0
- 5
consensus/reactor.go View File

@ -76,11 +76,8 @@ func (conR *ConsensusReactor) OnStart() error {
// OnStop implements BaseService // OnStop implements BaseService
func (conR *ConsensusReactor) OnStop() { func (conR *ConsensusReactor) OnStop() {
conR.Logger.Debug("conR.OnStop")
conR.BaseReactor.OnStop() conR.BaseReactor.OnStop()
conR.Logger.Debug("conR.OnStop: Stopping ConsensusState")
conR.conS.Stop() conR.conS.Stop()
conR.Logger.Debug("conR.OnStop: DONE")
} }
// SwitchToConsensus switches from fast_sync mode to consensus mode. // SwitchToConsensus switches from fast_sync mode to consensus mode.
@ -921,8 +918,6 @@ func (ps *PeerState) PickSendVote(votes types.VoteSetReader) bool {
msg := &VoteMessage{vote} msg := &VoteMessage{vote}
ps.logger.Debug("Sending vote message", "ps", ps, "vote", vote) ps.logger.Debug("Sending vote message", "ps", ps, "vote", vote)
return ps.Peer.Send(VoteChannel, struct{ ConsensusMessage }{msg}) return ps.Peer.Send(VoteChannel, struct{ ConsensusMessage }{msg})
} else {
ps.logger.Debug("No vote message to send", "ps", ps)
} }
return false return false
} }


+ 0
- 4
consensus/state.go View File

@ -267,18 +267,14 @@ func (cs *ConsensusState) startRoutines(maxSteps int) {
// OnStop implements cmn.Service. It stops all routines and waits for the WAL to finish. // OnStop implements cmn.Service. It stops all routines and waits for the WAL to finish.
func (cs *ConsensusState) OnStop() { func (cs *ConsensusState) OnStop() {
cs.Logger.Debug("conS.OnStop")
cs.BaseService.OnStop() cs.BaseService.OnStop()
cs.Logger.Debug("conS.OnStop: Stopping ticker")
cs.timeoutTicker.Stop() cs.timeoutTicker.Stop()
// Make BaseService.Wait() wait until cs.wal.Wait() // Make BaseService.Wait() wait until cs.wal.Wait()
cs.Logger.Debug("conS.OnStop: Waiting for WAL")
if cs.IsRunning() { if cs.IsRunning() {
cs.wal.Wait() cs.wal.Wait()
} }
cs.Logger.Debug("conS.OnStop: DONE")
} }
// Wait waits for the the main routine to return. // Wait waits for the the main routine to return.


+ 0
- 24
p2p/connection.go View File

@ -185,19 +185,13 @@ func (c *MConnection) OnStart() error {
// OnStop implements BaseService // OnStop implements BaseService
func (c *MConnection) OnStop() { func (c *MConnection) OnStop() {
c.Logger.Debug("MConn.OnStop")
c.BaseService.OnStop() c.BaseService.OnStop()
c.Logger.Debug("MConn.flushTimer.Stop")
c.flushTimer.Stop() c.flushTimer.Stop()
c.Logger.Debug("MConn.pingTimer.Stop")
c.pingTimer.Stop() c.pingTimer.Stop()
c.Logger.Debug("MConn.chStatsTimer.Stop")
c.chStatsTimer.Stop() c.chStatsTimer.Stop()
if c.quit != nil { if c.quit != nil {
c.Logger.Debug("MConn: Close Quit")
close(c.quit) close(c.quit)
} }
c.Logger.Debug("MConn.conn.Close()")
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
// recvRoutine may write to it after we've stopped. // recvRoutine may write to it after we've stopped.
@ -339,7 +333,6 @@ FOR_LOOP:
case <-c.send: case <-c.send:
// Send some msgPackets // Send some msgPackets
eof := c.sendSomeMsgPackets() eof := c.sendSomeMsgPackets()
c.Logger.Debug("finished sendSomeMsgPackets", "eof", eof)
if !eof { if !eof {
// Keep sendRoutine awake. // Keep sendRoutine awake.
select { select {
@ -359,7 +352,6 @@ FOR_LOOP:
} }
} }
c.Logger.Debug("sendRoutine: End")
// Cleanup // Cleanup
} }
@ -369,12 +361,10 @@ func (c *MConnection) sendSomeMsgPackets() bool {
// Block until .sendMonitor says we can write. // Block until .sendMonitor says we can write.
// Once we're ready we send more than we asked for, // Once we're ready we send more than we asked for,
// but amortized it should even out. // but amortized it should even out.
c.Logger.Debug("sendMonitor.Limit")
c.sendMonitor.Limit(c.config.maxMsgPacketTotalSize(), atomic.LoadInt64(&c.config.SendRate), true) c.sendMonitor.Limit(c.config.maxMsgPacketTotalSize(), atomic.LoadInt64(&c.config.SendRate), true)
// Now send some msgPackets. // Now send some msgPackets.
for i := 0; i < numBatchMsgPackets; i++ { for i := 0; i < numBatchMsgPackets; i++ {
c.Logger.Debug("sendMsgPacket", "i", i)
if c.sendMsgPacket() { if c.sendMsgPacket() {
return true return true
} }
@ -403,7 +393,6 @@ func (c *MConnection) sendMsgPacket() bool {
// Nothing to send? // Nothing to send?
if leastChannel == nil { if leastChannel == nil {
c.Logger.Debug("Least channel == nil")
return true return true
} else { } else {
// c.Logger.Info("Found a msgPacket to send") // c.Logger.Info("Found a msgPacket to send")
@ -416,7 +405,6 @@ func (c *MConnection) sendMsgPacket() bool {
c.stopForError(err) c.stopForError(err)
return true return true
} }
c.Logger.Debug("sendMonitor.Update")
c.sendMonitor.Update(int(n)) c.sendMonitor.Update(int(n))
c.flushTimer.Set() c.flushTimer.Set()
return false return false
@ -430,7 +418,6 @@ func (c *MConnection) recvRoutine() {
FOR_LOOP: FOR_LOOP:
for { for {
c.Logger.Debug("recvRoutine: recvMonitor.Limit")
// Block until .recvMonitor says we can read. // Block until .recvMonitor says we can read.
c.recvMonitor.Limit(c.config.maxMsgPacketTotalSize(), atomic.LoadInt64(&c.config.RecvRate), true) c.recvMonitor.Limit(c.config.maxMsgPacketTotalSize(), atomic.LoadInt64(&c.config.RecvRate), true)
@ -452,9 +439,7 @@ FOR_LOOP:
// Read packet type // Read packet type
var n int var n int
var err error var err error
c.Logger.Debug("recvRoutine: ReadByte")
pktType := wire.ReadByte(c.bufReader, &n, &err) pktType := wire.ReadByte(c.bufReader, &n, &err)
c.Logger.Debug("recvRoutine: recvMonitor.Update")
c.recvMonitor.Update(int(n)) c.recvMonitor.Update(int(n))
if err != nil { if err != nil {
if c.IsRunning() { if c.IsRunning() {
@ -470,15 +455,12 @@ FOR_LOOP:
// TODO: prevent abuse, as they cause flush()'s. // TODO: prevent abuse, as they cause flush()'s.
c.Logger.Debug("Receive Ping") c.Logger.Debug("Receive Ping")
c.pong <- struct{}{} c.pong <- struct{}{}
c.Logger.Debug("recvRoutine: trigger pong")
case packetTypePong: case packetTypePong:
// do nothing // do nothing
c.Logger.Debug("Receive Pong") c.Logger.Debug("Receive Pong")
case packetTypeMsg: case packetTypeMsg:
pkt, n, err := msgPacket{}, int(0), error(nil) pkt, n, err := msgPacket{}, int(0), error(nil)
c.Logger.Debug("recvRoutine: ReadBinaryPtr")
wire.ReadBinaryPtr(&pkt, c.bufReader, c.config.maxMsgPacketTotalSize(), &n, &err) wire.ReadBinaryPtr(&pkt, c.bufReader, c.config.maxMsgPacketTotalSize(), &n, &err)
c.Logger.Debug("recvRoutine: recvMonitor.Update")
c.recvMonitor.Update(int(n)) c.recvMonitor.Update(int(n))
if err != nil { if err != nil {
if c.IsRunning() { if c.IsRunning() {
@ -494,9 +476,7 @@ FOR_LOOP:
c.stopForError(err) c.stopForError(err)
} }
c.Logger.Debug("recvRoutine: recvMsgPacket")
msgBytes, err := channel.recvMsgPacket(pkt) msgBytes, err := channel.recvMsgPacket(pkt)
c.Logger.Debug("recvRoutine: msgBytes", "msgBytes", msgBytes, "err", err)
if err != nil { if err != nil {
if c.IsRunning() { if c.IsRunning() {
c.Logger.Error("Connection failed @ recvRoutine", "conn", c, "err", err) c.Logger.Error("Connection failed @ recvRoutine", "conn", c, "err", err)
@ -508,7 +488,6 @@ FOR_LOOP:
c.Logger.Debug("Received bytes", "chID", pkt.ChannelID, "msgBytes", msgBytes) c.Logger.Debug("Received bytes", "chID", pkt.ChannelID, "msgBytes", msgBytes)
// NOTE: This means the reactor.Receive runs in the same thread as the p2p recv routine // NOTE: This means the reactor.Receive runs in the same thread as the p2p recv routine
c.onReceive(pkt.ChannelID, msgBytes) c.onReceive(pkt.ChannelID, msgBytes)
c.Logger.Debug("done onReceive")
} }
default: default:
err := fmt.Errorf("Unknown message type %X", pktType) err := fmt.Errorf("Unknown message type %X", pktType)
@ -518,11 +497,8 @@ FOR_LOOP:
// TODO: shouldn't this go in the sendRoutine? // TODO: shouldn't this go in the sendRoutine?
// Better to send a ping packet when *we* haven't sent anything for a while. // Better to send a ping packet when *we* haven't sent anything for a while.
c.Logger.Debug("pingTimer.Reset()")
c.pingTimer.Reset() c.pingTimer.Reset()
c.Logger.Debug("done pingTimer.Reset()")
} }
c.Logger.Debug("recvRoutine: End")
// Cleanup // Cleanup
close(c.pong) close(c.pong)


+ 0
- 2
p2p/peer.go View File

@ -237,9 +237,7 @@ func (p *peer) OnStart() error {
// OnStop implements BaseService. // OnStop implements BaseService.
func (p *peer) OnStop() { func (p *peer) OnStop() {
p.Logger.Debug("Peer.OnStop")
p.BaseService.OnStop() p.BaseService.OnStop()
p.Logger.Debug("Peer.mconn.Stop")
p.mconn.Stop() p.mconn.Stop()
} }


+ 2
- 7
p2p/switch.go View File

@ -210,23 +210,18 @@ func (sw *Switch) OnStart() error {
// OnStop implements BaseService. It stops all listeners, peers, and reactors. // OnStop implements BaseService. It stops all listeners, peers, and reactors.
func (sw *Switch) OnStop() { func (sw *Switch) OnStop() {
// Stop listeners // Stop listeners
sw.Logger.Debug("Switch: Stopping listeners")
for _, listener := range sw.listeners { for _, listener := range sw.listeners {
listener.Stop() listener.Stop()
} }
sw.listeners = nil sw.listeners = nil
// Stop peers // Stop peers
sw.Logger.Debug("Switch: Stopping Peers")
for i, peer := range sw.peers.List() {
sw.Logger.Debug("Switch: Stopping peer", "i", i, "peer", peer)
for _, peer := range sw.peers.List() {
peer.Stop() peer.Stop()
sw.Logger.Debug("Switch: Removing peer", "i", i, "peer", peer)
sw.peers.Remove(peer) sw.peers.Remove(peer)
} }
// Stop reactors // Stop reactors
sw.Logger.Debug("Switch: Stopping reactors") sw.Logger.Debug("Switch: Stopping reactors")
for name, reactor := range sw.reactors {
sw.Logger.Debug("Switch: Stopping reactor", "name", name)
for _, reactor := range sw.reactors {
reactor.Stop() reactor.Stop()
} }
} }


Loading…
Cancel
Save