]> Cypherpunks repositories - gostls13.git/commitdiff
net: don't call forceCloseSockets in non-TestMain functions
authorMikio Hara <mikioh.mikioh@gmail.com>
Fri, 27 May 2016 18:06:33 +0000 (03:06 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Mon, 30 May 2016 03:30:14 +0000 (03:30 +0000)
forceCloseSockets is just designed as a kingston valve for TestMain
function and is not suitable to keep track of inflight sockets.

Fixes #15525.

Change-Id: Id967fe5b8da99bb08b699cc45e07bbc3dfc3ae3d
Reviewed-on: https://go-review.googlesource.com/23505
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/net/dial_test.go
src/net/main_plan9_test.go
src/net/main_unix_test.go
src/net/main_windows_test.go
src/net/timeout_test.go

index 53656770112a3a9e9c552811d62ddd4545b32192..9fe507e901f43e43855806dceb80d851cb783f6b 100644 (file)
@@ -87,17 +87,14 @@ func TestDialTimeoutFDLeak(t *testing.T) {
        // socktest.Switch.
        // It may happen when the Dial call bumps against TCP
        // simultaneous open. See selfConnect in tcpsock_posix.go.
-       defer func() {
-               sw.Set(socktest.FilterClose, nil)
-               forceCloseSockets()
-       }()
+       defer func() { sw.Set(socktest.FilterClose, nil) }()
        var mu sync.Mutex
        var attempts int
        sw.Set(socktest.FilterClose, func(so *socktest.Status) (socktest.AfterFilter, error) {
                mu.Lock()
                attempts++
                mu.Unlock()
-               return nil, errTimedout
+               return nil, nil
        })
 
        const N = 100
index 94501cada9a234afbd6c1556fed0f94e81d02e06..2bc5be88be6481b815b422cdfdde60882e60210f 100644 (file)
@@ -8,6 +8,7 @@ func installTestHooks() {}
 
 func uninstallTestHooks() {}
 
+// forceCloseSockets must be called only from TestMain.
 func forceCloseSockets() {}
 
 func enableSocketConnect() {}
index bfb4cd0065c937abd5360728192fad5d085ac7f1..0cc129f34ddae7205e1cc3aa417958f592b2b98d 100644 (file)
@@ -45,6 +45,7 @@ func uninstallTestHooks() {
        }
 }
 
+// forceCloseSockets must be called only from TestMain.
 func forceCloseSockets() {
        for s := range sw.Sockets() {
                closeFunc(s)
index b8797174258e5199096fb8f4adfb8a1f27ccbb70..6ea318c2a5f3a747da8dba620df3b96805909bf1 100644 (file)
@@ -32,6 +32,7 @@ func uninstallTestHooks() {
        acceptFunc = origAccept
 }
 
+// forceCloseSockets must be called only from TestMain.
 func forceCloseSockets() {
        for s := range sw.Sockets() {
                closeFunc(s)
index 7991a579fd1b349b1319688bbd0bf00aee4f48d1..14797eedb7b4f1f1837c91ba13ba3716f1f0a131 100644 (file)
@@ -41,19 +41,6 @@ func TestDialTimeout(t *testing.T) {
        defer func() { testHookDialChannel = origTestHookDialChannel }()
        defer sw.Set(socktest.FilterConnect, nil)
 
-       // Avoid tracking open-close jitterbugs between netFD and
-       // socket that leads to confusion of information inside
-       // socktest.Switch.
-       // It may happen when the Dial call bumps against TCP
-       // simultaneous open. See selfConnect in tcpsock_posix.go.
-       defer func() {
-               sw.Set(socktest.FilterClose, nil)
-               forceCloseSockets()
-       }()
-       sw.Set(socktest.FilterClose, func(so *socktest.Status) (socktest.AfterFilter, error) {
-               return nil, errTimedout
-       })
-
        for i, tt := range dialTimeoutTests {
                switch runtime.GOOS {
                case "plan9", "windows":