]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/tls: stop a timeout timer
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 15 Jan 2020 19:29:33 +0000 (19:29 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 15 Jan 2020 20:29:46 +0000 (20:29 +0000)
I noticed this leak while writing CL 214977.

Change-Id: I7566952b8e4bc58939d23435aea86576fc58ddca
Reviewed-on: https://go-review.googlesource.com/c/go/+/214978
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/crypto/tls/tls.go

index 228f4a79ab205f758ccee60db5f8de171fd88f13..af44485f44ebb758ad7e41c18656fa2cf24a44de 100644 (file)
@@ -116,9 +116,10 @@ func DialWithDialer(dialer *net.Dialer, network, addr string, config *Config) (*
 
        if timeout != 0 {
                errChannel = make(chan error, 2)
-               time.AfterFunc(timeout, func() {
+               timer := time.AfterFunc(timeout, func() {
                        errChannel <- timeoutError{}
                })
+               defer timer.Stop()
        }
 
        rawConn, err := dialer.Dial(network, addr)