Skip to content

Commit e786862

Browse files
authored
Remove direct read from TLS underlying conn (redis#3138)
1 parent d9eeed1 commit e786862

File tree

2 files changed

+0
-23
lines changed

2 files changed

+0
-23
lines changed

internal/pool/conn_check.go

-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package pool
44

55
import (
6-
"crypto/tls"
76
"errors"
87
"io"
98
"net"
@@ -17,10 +16,6 @@ func connCheck(conn net.Conn) error {
1716
// Reset previous timeout.
1817
_ = conn.SetDeadline(time.Time{})
1918

20-
// Check if tls.Conn.
21-
if c, ok := conn.(*tls.Conn); ok {
22-
conn = c.NetConn()
23-
}
2419
sysConn, ok := conn.(syscall.Conn)
2520
if !ok {
2621
return nil

internal/pool/conn_check_test.go

-18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package pool
44

55
import (
6-
"crypto/tls"
76
"net"
87
"net/http/httptest"
98
"time"
@@ -15,17 +14,12 @@ import (
1514
var _ = Describe("tests conn_check with real conns", func() {
1615
var ts *httptest.Server
1716
var conn net.Conn
18-
var tlsConn *tls.Conn
1917
var err error
2018

2119
BeforeEach(func() {
2220
ts = httptest.NewServer(nil)
2321
conn, err = net.DialTimeout(ts.Listener.Addr().Network(), ts.Listener.Addr().String(), time.Second)
2422
Expect(err).NotTo(HaveOccurred())
25-
tlsTestServer := httptest.NewUnstartedServer(nil)
26-
tlsTestServer.StartTLS()
27-
tlsConn, err = tls.DialWithDialer(&net.Dialer{Timeout: time.Second}, tlsTestServer.Listener.Addr().Network(), tlsTestServer.Listener.Addr().String(), &tls.Config{InsecureSkipVerify: true})
28-
Expect(err).NotTo(HaveOccurred())
2923
})
3024

3125
AfterEach(func() {
@@ -39,23 +33,11 @@ var _ = Describe("tests conn_check with real conns", func() {
3933
Expect(connCheck(conn)).To(HaveOccurred())
4034
})
4135

42-
It("good tls conn check", func() {
43-
Expect(connCheck(tlsConn)).NotTo(HaveOccurred())
44-
45-
Expect(tlsConn.Close()).NotTo(HaveOccurred())
46-
Expect(connCheck(tlsConn)).To(HaveOccurred())
47-
})
48-
4936
It("bad conn check", func() {
5037
Expect(conn.Close()).NotTo(HaveOccurred())
5138
Expect(connCheck(conn)).To(HaveOccurred())
5239
})
5340

54-
It("bad tls conn check", func() {
55-
Expect(tlsConn.Close()).NotTo(HaveOccurred())
56-
Expect(connCheck(tlsConn)).To(HaveOccurred())
57-
})
58-
5941
It("check conn deadline", func() {
6042
Expect(conn.SetDeadline(time.Now())).NotTo(HaveOccurred())
6143
time.Sleep(time.Millisecond * 10)

0 commit comments

Comments
 (0)