summaryrefslogtreecommitdiff
path: root/src/pkg/net/lookup_unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/net/lookup_unix.go')
-rw-r--r--src/pkg/net/lookup_unix.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/pkg/net/lookup_unix.go b/src/pkg/net/lookup_unix.go
index fa98eed5f..59e9f6321 100644
--- a/src/pkg/net/lookup_unix.go
+++ b/src/pkg/net/lookup_unix.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin freebsd linux netbsd openbsd
+// +build darwin dragonfly freebsd linux netbsd openbsd
package net
@@ -11,15 +11,11 @@ import (
"sync"
)
-var (
- protocols map[string]int
- onceReadProtocols sync.Once
-)
+var onceReadProtocols sync.Once
// readProtocols loads contents of /etc/protocols into protocols map
// for quick access.
func readProtocols() {
- protocols = make(map[string]int)
if file, err := open("/etc/protocols"); err == nil {
for line, ok := file.readLine(); ok; line, ok = file.readLine() {
// tcp 6 TCP # transmission control protocol
@@ -31,9 +27,13 @@ func readProtocols() {
continue
}
if proto, _, ok := dtoi(f[1], 0); ok {
- protocols[f[0]] = proto
+ if _, ok := protocols[f[0]]; !ok {
+ protocols[f[0]] = proto
+ }
for _, alias := range f[2:] {
- protocols[alias] = proto
+ if _, ok := protocols[alias]; !ok {
+ protocols[alias] = proto
+ }
}
}
}