gomodule/redigo

Close TLS connection if handshake timeout

Oleglacto opened this issue · 4 comments

If TLS enabled and we got tlsHandshakeTimeoutError, we will not close TLS connection here

I suggest next improvements:

                innerCtx, cancel := context.WithCancel(ctx) // new
		if d := do.tlsHandshakeTimeout; d != 0 {
			timer := time.AfterFunc(d, func() {
				cancel()
				errc <- tlsHandshakeTimeoutError{}
			})
			defer timer.Stop()
		}
		
		go func() {
			errc <- tlsConn.HandshakeContext(innerCtx) // new
		}()

If we got timeout, TLS package close connection by cancel ctx here.

I think it's easiest solution of connection leak

Looks reasonable @Oleglacto happy to take a PR.

How to make pr? I can't push into rep

You create a fork, push to your fork on a new branch e.g. fix/tls-close then raise a PR from that.

Sorry, i made deep research for this issue, and it's works fine.