Skip to content

Commit e510abc

Browse files
committed
net/dnscache: don't cancel the TLS context before writing to the result channel.
Cancelling the context makes the timeout goroutine race with the write that reports a successful TLS handshake, so you can end up with a successful TLS handshake that mysteriously reports that it timed out after ~0s in flight. The context is always canceled and cleaned up as the function exits, which happens mere microseconds later, so just let function exit clean up and thereby avoid races. Signed-off-by: David Anderson <danderson@tailscale.com> (cherry picked from commit a9da6b7)
1 parent 958917d commit e510abc

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

net/dnscache/dnscache.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,7 @@ func TLSDialer(fwd DialContextFunc, dnsCache *Resolver, tlsConfigBase *tls.Confi
457457
}
458458
}()
459459
go func() {
460-
err := tlsConn.Handshake()
461-
handshakeTimeoutCancel()
462-
errc <- err
460+
errc <- tlsConn.Handshake()
463461
}()
464462
if err := <-errc; err != nil {
465463
tcpConn.Close()

0 commit comments

Comments
 (0)