mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
les: fixed peer reply error handling
This commit is contained in:
parent
1cd1b017cf
commit
f0b079e897
2 changed files with 10 additions and 1 deletions
|
|
@ -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:
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue