OSDN Git Service
(root)
/
bytom
/
bytom.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
48890fe
)
Add peer close connection waite
author
Yahtoo Ma
<yahtoo.ma@gmail.com>
Tue, 8 May 2018 08:04:33 +0000
(16:04 +0800)
committer
Yahtoo Ma
<yahtoo.ma@gmail.com>
Tue, 8 May 2018 08:04:33 +0000
(16:04 +0800)
p2p/pex_reactor.go
patch
|
blob
|
history
diff --git
a/p2p/pex_reactor.go
b/p2p/pex_reactor.go
index
44ff6f2
..
be6f75d
100644
(file)
--- a/
p2p/pex_reactor.go
+++ b/
p2p/pex_reactor.go
@@
-128,10
+128,14
@@
func (r *PEXReactor) AddPeer(p *Peer) error {
// close the connect if connect is big than max limit
if r.sw.peers.Size() >= r.sw.config.MaxNumPeers {
if ok := r.SendAddrs(p, r.book.GetSelection()); ok {
- r.sw.StopPeerGracefully(p)
+ select {
+ case <-time.After(1 * time.Second):
+ r.sw.StopPeerGracefully(p)
+ }
}
return errors.New("Error in AddPeer: reach the max peer, exchange then close")
}
+
return nil
}