From c7276ee51ed3f9eeb720ab003e24f80303a7ce08 Mon Sep 17 00:00:00 2001 From: Nao Yokotsuka <32049413+yokonao@users.noreply.github.com> Date: Sun, 4 Aug 2024 16:52:29 +0900 Subject: [PATCH] Check mysqlConnector.canceled.Value when failed to TLS handshake (#1615) ### Description Check if the context is canceled when failed to TLS handshake. fix: #1614 ### Checklist - [x] Code compiles correctly - [x] Created tests which fail without the change (if possible) - [x] All tests passing - [x] Extended the README / documentation, if necessary - [x] Added myself / the copyright holder to the AUTHORS file ## Summary by CodeRabbit - **New Features** - Added Nao Yokotsuka to the contributors list for improved project documentation. - **Bug Fixes** - Enhanced error handling in the TLS handshake process to better manage cancellation requests, improving connection responsiveness. --- AUTHORS | 1 + packets.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/AUTHORS b/AUTHORS index bab66a3b..287176fb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -81,6 +81,7 @@ Lunny Xiao Luke Scott Maciej Zimnoch Michael Woolnough +Nao Yokotsuka Nathanial Murphy Nicola Peduzzi Oliver Bone diff --git a/packets.go b/packets.go index ccdd532b..5ca6491a 100644 --- a/packets.go +++ b/packets.go @@ -352,6 +352,9 @@ func (mc *mysqlConn) writeHandshakeResponsePacket(authResp []byte, plugin string // Switch to TLS tlsConn := tls.Client(mc.netConn, mc.cfg.TLS) if err := tlsConn.Handshake(); err != nil { + if cerr := mc.canceled.Value(); cerr != nil { + return cerr + } return err } mc.netConn = tlsConn