summaryrefslogtreecommitdiffhomepage
path: root/pkg/server/sockopt_linux_test.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-12-01 22:20:18 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-12-19 20:11:56 +0900
commit598bba9fb2b761d1ad32776b0a61357500227de1 (patch)
tree02737038dc8c6b330cdf7690bc6cb3be2b3c8fe6 /pkg/server/sockopt_linux_test.go
parent831b33fdb75074f7fbc19c6a7b966e1633ad5200 (diff)
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 <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'pkg/server/sockopt_linux_test.go')
-rw-r--r--pkg/server/sockopt_linux_test.go40
1 files changed, 0 insertions, 40 deletions
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)
- }
-}