Browse Source

Be more strict about file closing in bind

This eliminates the race condition mentioned in a54c913a by forbidding
duplicate binds to the same socket (well, at least in the sense that
attempting to do so will *always* result in an error instead of
nondeterministically resulting in an error).
Carl Jackson 12 years ago
parent
commit
6bc38f39b3
2 changed files with 2 additions and 0 deletions
  1. +1
    -0
      bind/bind.go
  2. +1
    -0
      bind/einhorn.go

+ 1
- 0
bind/bind.go View File

@ -75,6 +75,7 @@ func listenTo(bind string) (net.Listener, error) {
bind, err) bind, err)
} }
f := os.NewFile(uintptr(fd), bind) f := os.NewFile(uintptr(fd), bind)
defer f.Close()
return net.FileListener(f) return net.FileListener(f)
} else if strings.HasPrefix(bind, "einhorn@") { } else if strings.HasPrefix(bind, "einhorn@") {
fd, err := strconv.Atoi(bind[8:]) fd, err := strconv.Atoi(bind[8:])


+ 1
- 0
bind/einhorn.go View File

@ -65,6 +65,7 @@ func einhornBind(n int) (net.Listener, error) {
fno := einhornFdMap(n) fno := einhornFdMap(n)
f := os.NewFile(uintptr(fno), fmt.Sprintf("einhorn@%d", n)) f := os.NewFile(uintptr(fno), fmt.Sprintf("einhorn@%d", n))
defer f.Close()
return net.FileListener(f) return net.FileListener(f)
} }


Loading…
Cancel
Save