mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
add lock to resolve
This commit is contained in:
parent
e31709db65
commit
e66c6c0512
1 changed files with 5 additions and 0 deletions
|
|
@ -94,6 +94,7 @@ type dialScheduler struct {
|
||||||
dialConfig
|
dialConfig
|
||||||
setupFunc dialSetupFunc
|
setupFunc dialSetupFunc
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
lock sync.Mutex
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
nodesIn chan *enode.Node
|
nodesIn chan *enode.Node
|
||||||
|
|
@ -409,6 +410,8 @@ func (d *dialScheduler) startStaticDials(n int) (started int) {
|
||||||
|
|
||||||
// updateStaticPool attempts to move the given static dial back into staticPool.
|
// updateStaticPool attempts to move the given static dial back into staticPool.
|
||||||
func (d *dialScheduler) updateStaticPool(id enode.ID) {
|
func (d *dialScheduler) updateStaticPool(id enode.ID) {
|
||||||
|
d.lock.Lock()
|
||||||
|
defer d.lock.Unlock()
|
||||||
task, ok := d.static[id]
|
task, ok := d.static[id]
|
||||||
if ok && task.staticPoolIndex < 0 && d.checkDial(task.dest) == nil {
|
if ok && task.staticPoolIndex < 0 && d.checkDial(task.dest) == nil {
|
||||||
d.addToStaticPool(task)
|
d.addToStaticPool(task)
|
||||||
|
|
@ -493,6 +496,8 @@ func (t *dialTask) needResolve() bool {
|
||||||
// discovery network with useless queries for nodes that don't exist.
|
// discovery network with useless queries for nodes that don't exist.
|
||||||
// The backoff delay resets when the node is found.
|
// The backoff delay resets when the node is found.
|
||||||
func (t *dialTask) resolve(d *dialScheduler) bool {
|
func (t *dialTask) resolve(d *dialScheduler) bool {
|
||||||
|
d.lock.Lock()
|
||||||
|
defer d.lock.Unlock()
|
||||||
if d.resolver == nil {
|
if d.resolver == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue