# HG changeset patch # User Sebastien Paolacci # Date 1321029694 -3600 # Node ID 70f1e649c227e7c1528145a953bea3a8e96f54b9 # Parent 000602776246da83af2daff6a2ad27b0a41717ba net: don't alter fd blocking mode when calling File() Breaks timeouts and doesn't bring additional safety/comfort. diff -r 000602776246 -r 70f1e649c227 src/pkg/net/fd.go --- a/src/pkg/net/fd.go Fri Nov 11 21:44:01 2011 +1100 +++ b/src/pkg/net/fd.go Fri Nov 11 17:41:34 2011 +0100 @@ -652,12 +652,6 @@ if e != 0 { return nil, &OpError{"dup", fd.net, fd.laddr, os.Errno(e)} } - - // We want blocking mode for the new fd, hence the double negative. - if e = syscall.SetNonblock(ns, false); e != 0 { - return nil, &OpError{"setnonblock", fd.net, fd.laddr, os.Errno(e)} - } - return os.NewFile(ns, fd.sysfile.Name()), nil } diff -r 000602776246 -r 70f1e649c227 src/pkg/net/iprawsock_posix.go --- a/src/pkg/net/iprawsock_posix.go Fri Nov 11 21:44:01 2011 +1100 +++ b/src/pkg/net/iprawsock_posix.go Fri Nov 11 17:41:34 2011 +0100 @@ -277,7 +277,7 @@ return os.NewSyscallError("setsockopt", syscall.BindToDevice(c.fd.sysfd, device)) } -// File returns a copy of the underlying os.File, set to blocking mode. +// File returns a copy of the underlying os.File in non-blocking mode. // It is the caller's responsibility to close f when finished. // Closing c does not affect f, and closing f does not affect c. func (c *IPConn) File() (f *os.File, err error) { return c.fd.dup() } diff -r 000602776246 -r 70f1e649c227 src/pkg/net/tcpsock_posix.go --- a/src/pkg/net/tcpsock_posix.go Fri Nov 11 21:44:01 2011 +1100 +++ b/src/pkg/net/tcpsock_posix.go Fri Nov 11 17:41:34 2011 +0100 @@ -214,7 +214,7 @@ return setNoDelay(c.fd, noDelay) } -// File returns a copy of the underlying os.File, set to blocking mode. +// File returns a copy of the underlying os.File in non-blocking mode. // It is the caller's responsibility to close f when finished. // Closing c does not affect f, and closing f does not affect c. func (c *TCPConn) File() (f *os.File, err error) { return c.fd.dup() } @@ -302,7 +302,7 @@ return setTimeout(l.fd, nsec) } -// File returns a copy of the underlying os.File, set to blocking mode. +// File returns a copy of the underlying os.File in non-blocking mode. // It is the caller's responsibility to close f when finished. // Closing c does not affect f, and closing f does not affect c. func (l *TCPListener) File() (f *os.File, err error) { return l.fd.dup() } diff -r 000602776246 -r 70f1e649c227 src/pkg/net/udpsock_posix.go --- a/src/pkg/net/udpsock_posix.go Fri Nov 11 21:44:01 2011 +1100 +++ b/src/pkg/net/udpsock_posix.go Fri Nov 11 17:41:34 2011 +0100 @@ -250,7 +250,7 @@ return os.NewSyscallError("setsockopt", syscall.BindToDevice(c.fd.sysfd, device)) } -// File returns a copy of the underlying os.File, set to blocking mode. +// File returns a copy of the underlying os.File in non-blocking mode. // It is the caller's responsibility to close f when finished. // Closing c does not affect f, and closing f does not affect c. func (c *UDPConn) File() (f *os.File, err error) { return c.fd.dup() } diff -r 000602776246 -r 70f1e649c227 src/pkg/net/unixsock_posix.go --- a/src/pkg/net/unixsock_posix.go Fri Nov 11 21:44:01 2011 +1100 +++ b/src/pkg/net/unixsock_posix.go Fri Nov 11 17:41:34 2011 +0100 @@ -289,7 +289,7 @@ return c.fd.WriteMsg(b, oob, nil) } -// File returns a copy of the underlying os.File, set to blocking mode. +// File returns a copy of the underlying os.File in non-blocking mode. // It is the caller's responsibility to close f when finished. // Closing c does not affect f, and closing f does not affect c. func (c *UnixConn) File() (f *os.File, err error) { return c.fd.dup() } @@ -394,7 +394,7 @@ return setTimeout(l.fd, nsec) } -// File returns a copy of the underlying os.File, set to blocking mode. +// File returns a copy of the underlying os.File in non-blocking mode. // It is the caller's responsibility to close f when finished. // Closing c does not affect f, and closing f does not affect c. func (l *UnixListener) File() (f *os.File, err error) { return l.fd.dup() }