Skip to content

Commit ff1dab4

Browse files
authored
client: Fix timeout reset during TLS handshake (#925)
This commit fixes `(*client.Conn).writeAuthHandshake()` to use `packet.NewConnWithTimeout` instead of `packet.NewBufferedConn` when recreating the packet connection after switching TLS on. This preserves the connection read/write timeout settings which would otherwise be reset to zero. Since this code executes after some reads and writes have already taken place, and the packet connection code only sets a deadline when the timeout values are nonzero, the result was that previously when connecting using TLS and with a read and/or write timeout set, the connection would inevitably fail just one timeout-duration after being opened. This use of `packet.NewBufferedConn` appears to be the only place in the `client` package where a packet connection was recreated without the timeout configuration being plumbed through.
1 parent c435689 commit ff1dab4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

client/auth.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func (c *Conn) writeAuthHandshake() error {
304304
}
305305

306306
currentSequence := c.Sequence
307-
c.Conn = packet.NewBufferedConn(tlsConn, c.BufferSize)
307+
c.Conn = packet.NewConnWithTimeout(tlsConn, c.ReadTimeout, c.WriteTimeout, c.BufferSize)
308308
c.Sequence = currentSequence
309309
}
310310

0 commit comments

Comments
 (0)