Remove dead link code

This commit is contained in:
Asim Aslam
2019-09-11 11:57:41 -07:00
parent 9ca7d90f11
commit 6819386e05
4 changed files with 27 additions and 119 deletions

View File

@@ -932,6 +932,11 @@ func (t *tun) Dial(channel string, opts ...DialOption) (Session, error) {
// non multicast so we need to find the link
t.RLock()
for _, link := range t.links {
// use the link specified it its available
if id := options.Link; len(id) > 0 && link.id != id {
continue
}
link.RLock()
_, ok := link.channels[channel]
link.RUnlock()
@@ -944,6 +949,11 @@ func (t *tun) Dial(channel string, opts ...DialOption) (Session, error) {
}
t.RUnlock()
// link not found
if len(links) == 0 && len(options.Link) > 0 {
return nil, ErrLinkNotFound
}
// discovered so set the link if not multicast
// TODO: pick the link efficiently based
// on link status and saturation.