From 598bba9fb2b761d1ad32776b0a61357500227de1 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sat, 1 Dec 2018 22:20:18 +0900 Subject: server: use Dialer Control method instead of hack to modify connection before dialing Use the feature of go 1.11 to remove the hack. Signed-off-by: FUJITA Tomonori --- pkg/server/sockopt_linux_test.go | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'pkg/server/sockopt_linux_test.go') diff --git a/pkg/server/sockopt_linux_test.go b/pkg/server/sockopt_linux_test.go index ca72a98f..d9ca3d5e 100644 --- a/pkg/server/sockopt_linux_test.go +++ b/pkg/server/sockopt_linux_test.go @@ -18,12 +18,8 @@ package server import ( "bytes" - "fmt" - "net" - "os" "syscall" "testing" - "time" "unsafe" ) @@ -68,39 +64,3 @@ func Test_buildTcpMD5Sigv6(t *testing.T) { t.Error("Something wrong v6") } } - -func Test_DialTCP_FDleak(t *testing.T) { - openFds := func() int { - pid := os.Getpid() - f, err := os.OpenFile(fmt.Sprintf("/proc/%d/fdinfo", pid), os.O_RDONLY, 0) - if err != nil { - t.Fatal(err) - } - defer f.Close() - names, err := f.Readdirnames(0) - if err != nil { - t.Fatal(err) - } - return len(names) - } - - before := openFds() - - for i := 0; i < 10; i++ { - laddr, _ := net.ResolveTCPAddr("tcp", net.JoinHostPort("127.0.0.1", "0")) - d := tcpDialer{ - Dialer: net.Dialer{ - LocalAddr: laddr, - Timeout: 1 * time.Second, - }, - } - if _, err := d.DialTCP("127.0.0.1", 1); err == nil { - t.Fatalf("should not succeed") - } - - } - - if after := openFds(); before != after { - t.Fatalf("could be fd leak, %d %d", before, after) - } -} -- cgit v1.2.3