diff options
Diffstat (limited to 'libgo/go/net/file_unix.go')
-rw-r--r-- | libgo/go/net/file_unix.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libgo/go/net/file_unix.go b/libgo/go/net/file_unix.go index 4c8403e4063..8fe1b0eb035 100644 --- a/libgo/go/net/file_unix.go +++ b/libgo/go/net/file_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 @@ -12,14 +12,11 @@ import ( ) func newFileFD(f *os.File) (*netFD, error) { - syscall.ForkLock.RLock() - fd, err := syscall.Dup(int(f.Fd())) + fd, err := dupCloseOnExec(int(f.Fd())) if err != nil { - syscall.ForkLock.RUnlock() return nil, os.NewSyscallError("dup", err) } - syscall.CloseOnExec(fd) - syscall.ForkLock.RUnlock() + if err = syscall.SetNonblock(fd, true); err != nil { closesocket(fd) return nil, err @@ -70,6 +67,10 @@ func newFileFD(f *os.File) (*netFD, error) { closesocket(fd) return nil, err } + if err := netfd.init(); err != nil { + netfd.Close() + return nil, err + } netfd.setAddr(laddr, raddr) return netfd, nil } |