bsc/p2p
Jolly Zhao 15bc2548c1
fix logic issue: handlers.removePeer() is called twice. (#856)
* fix logic issue: handlers.removePeer() is called twice.

There is a logic issue which cause "Ethereum peer removal failed, err=peer not registered" occur quite often.

handler.runEthPeer set up a defer removePeer(). This is always called after a peer is disconnected.
However removePeer is also called by mulitple functions like downloader/fetcher.  After those kind of functions removePeer(), peer handler executes defer removePeer(). This makes removePeer() happened twice, and this is the reason we often see "Ethereum peer removal failed, err=peer not registered".

To solve this, removePeer only needs to hard Disconnect peer from networking layer. Then defer unregisterPeer() will do the cleanup task after then.

* fix: modify test function for close testing.

reference from go-thereum.

Co-authored-by: zjubfd <296179868@qq.com>
2022-04-24 14:24:07 +08:00
..
discover [R4R] performance improvement in many aspects (#257) 2021-07-29 17:16:53 +08:00
dnsdisc cmd/utils: use eth DNS tree for snap discovery (#22808) 2021-05-04 11:29:32 +02:00
enode [R4R] performance improvement in many aspects (#257) 2021-07-29 17:16:53 +08:00
enr p2p/enr: fix decoding of incomplete lists (#22484) 2021-03-11 15:09:25 +01:00
nat [R4R] performance improvement in many aspects (#257) 2021-07-29 17:16:53 +08:00
netutil p2p/discover: implement v5.1 wire protocol (#21647) 2020-10-14 12:28:17 +02:00
nodestate les: move client pool to les/vflux/server (#22495) 2021-04-06 20:42:50 +02:00
rlpx [R4R] performance improvement in many aspects (#257) 2021-07-29 17:16:53 +08:00
simulations [R4R] performance improvement in many aspects (#257) 2021-07-29 17:16:53 +08:00
tracker p2p/tracker: only reschedule wake if previous didn't run 2021-04-27 21:47:59 +03:00
dial_test.go p2p: new dial scheduler (#20592) 2020-02-13 11:10:03 +01:00
dial.go [R4R] performance improvement in many aspects (#257) 2021-07-29 17:16:53 +08:00
message_test.go p2p: move rlpx into separate package (#21464) 2020-09-22 10:17:39 +02:00
message.go eth: implement eth66 (#22241) 2021-02-18 18:54:29 +02:00
metrics.go eth/protocols, prp/tracker: add support for req/rep rtt tracking (#22608) 2021-04-22 11:42:46 +03:00
peer_error.go p2p: fix some golint warnings (#16577) 2018-05-08 13:08:43 +02:00
peer_test.go p2p: move rlpx into separate package (#21464) 2020-09-22 10:17:39 +02:00
peer.go fix logic issue: handlers.removePeer() is called twice. (#856) 2022-04-24 14:24:07 +08:00
protocol.go cmd/devp2p, p2p: dial using node iterator, discovery crawler (#20132) 2019-10-29 17:08:57 +02:00
server_test.go [R4R] add timeout for stopping p2p server (#643) 2021-12-13 11:16:03 +08:00
server.go [R4R] add timeout for stopping p2p server (#643) 2021-12-13 11:16:03 +08:00
transport_test.go p2p: move rlpx into separate package (#21464) 2020-09-22 10:17:39 +02:00
transport.go [R4R] performance improvement in many aspects (#257) 2021-07-29 17:16:53 +08:00
util_test.go p2p: new dial scheduler (#20592) 2020-02-13 11:10:03 +01:00
util.go p2p: new dial scheduler (#20592) 2020-02-13 11:10:03 +01:00