aboutsummaryrefslogtreecommitdiffstats
path: root/les/helper_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-01-09 22:58:23 +0800
committerGitHub <noreply@github.com>2017-01-09 22:58:23 +0800
commit681b51aac46fa11c235e9ac1af1228e0105a0720 (patch)
treeecbd5467a5f7356b2386189a67b8629663068cec /les/helper_test.go
parent4268cb8efecceaf506e1b0b71e06714a838a49a8 (diff)
parent66979aa468b6329aabf49542bd3db14e59010c20 (diff)
downloaddexon-681b51aac46fa11c235e9ac1af1228e0105a0720.tar.gz
dexon-681b51aac46fa11c235e9ac1af1228e0105a0720.tar.zst
dexon-681b51aac46fa11c235e9ac1af1228e0105a0720.zip
Merge pull request #3519 from zsfelfoldi/light-topic5
les: fixed selectPeer deadlock, improved request distribution
Diffstat (limited to 'les/helper_test.go')
-rw-r--r--les/helper_test.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/les/helper_test.go b/les/helper_test.go
index ec98389cb..3d6bf3c29 100644
--- a/les/helper_test.go
+++ b/les/helper_test.go
@@ -336,10 +336,23 @@ func (p *testPeer) close() {
p.app.Close()
}
-type testServerPool peer
+type testServerPool struct {
+ peer *peer
+ lock sync.RWMutex
+}
+
+func (p *testServerPool) setPeer(peer *peer) {
+ p.lock.Lock()
+ defer p.lock.Unlock()
+
+ p.peer = peer
+}
+
+func (p *testServerPool) selectPeerWait(uint64, func(*peer) (bool, time.Duration), <-chan struct{}) *peer {
+ p.lock.RLock()
+ defer p.lock.RUnlock()
-func (p *testServerPool) selectPeer(func(*peer) (bool, uint64)) *peer {
- return (*peer)(p)
+ return p.peer
}
func (p *testServerPool) adjustResponseTime(*poolEntry, time.Duration, bool) {