From f0b079e897d94e2328fa363ee7dda096d5c18efe Mon Sep 17 00:00:00 2001 From: Zsolt Felfoldi Date: Sun, 10 Mar 2019 00:43:35 +0100 Subject: [PATCH] les: fixed peer reply error handling --- les/handler.go | 10 +++++++++- les/peer.go | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/les/handler.go b/les/handler.go index 0352f5b039..6b95f6a9bc 100644 --- a/les/handler.go +++ b/les/handler.go @@ -329,6 +329,11 @@ func (pm *ProtocolManager) handle(p *peer) error { // handleMsg is invoked whenever an inbound message is received from a remote // peer. The remote connection is torn down upon returning any error. func (pm *ProtocolManager) handleMsg(p *peer) error { + select { + case err := <-p.errCh: + return err + default: + } // Read the next message from the remote peer, and ensure it's fully consumed msg, err := p.rw.ReadMsg() if err != nil { @@ -389,7 +394,10 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { if reply != nil { p.queueSend(func() { if err := reply.send(bv); err != nil { - p.errCh <- err + select { + case p.errCh <- err: + default: + } } }) } diff --git a/les/peer.go b/les/peer.go index 1cacf3b5ad..0c15add9c6 100644 --- a/les/peer.go +++ b/les/peer.go @@ -105,6 +105,7 @@ func newPeer(version int, network uint64, isTrusted bool, p *p2p.Peer, rw p2p.Ms network: network, id: fmt.Sprintf("%x", p.ID().Bytes()), isTrusted: isTrusted, + errCh: make(chan error, 1), } }