Commit 68bf5666 authored by Nicolas Owens's avatar Nicolas Owens Committed by Russ Cox

net: only return unique hosts during hostname lookup on plan 9

TestLookupHost expects that no duplicate addresses are returned. when cs is consulted for a name, e.g net!localhost!1, it will possibly return multiple available paths, e.g. via il and tcp. this confuses the tests.

LGTM=aram
R=jas, 0intro, aram
CC=golang-codereviews
https://golang.org/cl/58120045
parent 87d58f44
......@@ -123,6 +123,7 @@ func lookupHost(host string) (addrs []string, err error) {
if err != nil {
return
}
loop:
for _, line := range lines {
f := getFields(line)
if len(f) < 2 {
......@@ -135,6 +136,12 @@ func lookupHost(host string) (addrs []string, err error) {
if ParseIP(addr) == nil {
continue
}
// only return unique addresses
for _, a := range addrs {
if a == addr {
continue loop
}
}
addrs = append(addrs, addr)
}
return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment