]> Cypherpunks repositories - gostls13.git/commitdiff
net: only return unique hosts during hostname lookup on plan 9
authorNicolas Owens <mischief@offblast.org>
Thu, 13 Feb 2014 15:26:16 +0000 (10:26 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 13 Feb 2014 15:26:16 +0000 (10:26 -0500)
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

src/pkg/net/lookup_plan9.go

index 723f29ffce19ca3f9189ec86c2da5229548475a0..2ccd997c2cba1b7efb15a798b6da6f22cebce83d 100644 (file)
@@ -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