diff options
author | Zsolt Felfoldi <zsfelfoldi@gmail.com> | 2016-12-15 18:13:52 +0800 |
---|---|---|
committer | Zsolt Felfoldi <zsfelfoldi@gmail.com> | 2017-01-06 11:34:31 +0800 |
commit | 93f9c023ccda2256079484d6c2a3159818ba6691 (patch) | |
tree | f2ed341904459184587ca1cc8667d8169761f752 /les/helper_test.go | |
parent | e0ee0cc66a4416edd47232649f4d4bca4a5e3c07 (diff) | |
download | dexon-93f9c023ccda2256079484d6c2a3159818ba6691.tar.gz dexon-93f9c023ccda2256079484d6c2a3159818ba6691.tar.zst dexon-93f9c023ccda2256079484d6c2a3159818ba6691.zip |
les: fixed selectPeer deadlock, improved request distribution
les/flowcontrol: using proper types for relative and absolute times
Diffstat (limited to 'les/helper_test.go')
-rw-r--r-- | les/helper_test.go | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/les/helper_test.go b/les/helper_test.go index 2df3faab2..0d1aba9a5 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) { |