]> Cypherpunks repositories - gostls13.git/commitdiff
net: calling File leaves the socket in nonblocking mode
authorMichael Fraenkel <michael.fraenkel@gmail.com>
Thu, 19 Apr 2018 21:54:29 +0000 (17:54 -0400)
committerIan Lance Taylor <iant@golang.org>
Thu, 19 Apr 2018 23:33:09 +0000 (23:33 +0000)
On Unix systems, the underlying socket is no longer forced into blocking
mode.

Fixes #24942

Change-Id: I3e0c503c72df0844e30a63af298691dedacd1f46
Reviewed-on: https://go-review.googlesource.com/108297
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/net/fd_unix.go
src/net/net.go
src/net/tcpsock.go
src/net/unixsock.go

index efe2e184afcb1f6b6a5f38252eed6a6bb0d3cf2d..145933e7377efcc205198a91b0fd65442988829c 100644 (file)
@@ -309,13 +309,5 @@ func (fd *netFD) dup() (f *os.File, err error) {
                return nil, err
        }
 
-       // We want blocking mode for the new fd, hence the double negative.
-       // This also puts the old fd into blocking mode, meaning that
-       // I/O will block the thread instead of letting us use the epoll server.
-       // Everything will still work, just with more threads.
-       if err = fd.pfd.SetBlocking(); err != nil {
-               return nil, os.NewSyscallError("setnonblock", err)
-       }
-
        return os.NewFile(uintptr(ns), fd.name()), nil
 }
index 5182c0de95632b8f12d594d24b662847d27d5d52..b023d7c93f82ea71ca41e9efb54890639c8409a2 100644 (file)
@@ -281,15 +281,13 @@ func (c *conn) SetWriteBuffer(bytes int) error {
        return nil
 }
 
-// File sets the underlying os.File to blocking mode and returns a copy.
+// File returns a copy of the underlying os.File
 // It is the caller's responsibility to close f when finished.
 // Closing c does not affect f, and closing f does not affect c.
 //
 // The returned os.File's file descriptor is different from the connection's.
 // Attempting to change properties of the original using this duplicate
 // may or may not have the desired effect.
-//
-// On Unix systems this will cause the SetDeadline methods to stop working.
 func (c *conn) File() (f *os.File, err error) {
        f, err = c.fd.dup()
        if err != nil {
index 9528140b940ee108b095f3b379940f18e4a54db1..0421ce56749d5e662c77ede3260d50d1949764df 100644 (file)
@@ -292,8 +292,8 @@ func (l *TCPListener) SetDeadline(t time.Time) error {
        return nil
 }
 
-// File returns a copy of the underlying os.File, set to blocking
-// mode. It is the caller's responsibility to close f when finished.
+// File returns a copy of the underlying os.File.
+// It is the caller's responsibility to close f when finished.
 // Closing l does not affect f, and closing f does not affect l.
 //
 // The returned os.File's file descriptor is different from the
index 20326dabeaa9cf72da15fc325358fe64bc600eb6..551280f93622e47358db8cef0b94d8717f966a44 100644 (file)
@@ -286,8 +286,8 @@ func (l *UnixListener) SetDeadline(t time.Time) error {
        return nil
 }
 
-// File returns a copy of the underlying os.File, set to blocking
-// mode. It is the caller's responsibility to close f when finished.
+// File returns a copy of the underlying os.File.
+// It is the caller's responsibility to close f when finished.
 // Closing l does not affect f, and closing f does not affect l.
 //
 // The returned os.File's file descriptor is different from the