Merge pull request #721 from micro/tunnel
Separate lookup nodes and setup nodes
This commit is contained in:
commit
6c3631728b
@ -132,17 +132,28 @@ func (t *tun) monitor() {
|
|||||||
case <-t.closed:
|
case <-t.closed:
|
||||||
return
|
return
|
||||||
case <-reconnect.C:
|
case <-reconnect.C:
|
||||||
|
var connect []string
|
||||||
|
|
||||||
|
// build list of unknown nodes to connect to
|
||||||
|
t.RLock()
|
||||||
for _, node := range t.options.Nodes {
|
for _, node := range t.options.Nodes {
|
||||||
t.Lock()
|
|
||||||
if _, ok := t.links[node]; !ok {
|
if _, ok := t.links[node]; !ok {
|
||||||
link, err := t.setupLink(node)
|
connect = append(connect, node)
|
||||||
if err != nil {
|
|
||||||
log.Debugf("Tunnel failed to setup node link to %s: %v", node, err)
|
|
||||||
t.Unlock()
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
t.links[node] = link
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
t.RUnlock()
|
||||||
|
|
||||||
|
for _, node := range connect {
|
||||||
|
// create new link
|
||||||
|
link, err := t.setupLink(node)
|
||||||
|
if err != nil {
|
||||||
|
log.Debugf("Tunnel failed to setup node link to %s: %v", node, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// save the link
|
||||||
|
t.Lock()
|
||||||
|
t.links[node] = link
|
||||||
t.Unlock()
|
t.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user