Skip to content

Commit

Permalink
Check mysqlConnector.canceled.Value when failed to TLS handshake (#1615)
Browse files Browse the repository at this point in the history
### 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


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## 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.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
yokonao authored Aug 4, 2024
1 parent 44553d6 commit c7276ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Lunny Xiao <xiaolunwen at gmail.com>
Luke Scott <luke at webconnex.com>
Maciej Zimnoch <maciej.zimnoch at codilime.com>
Michael Woolnough <michael.woolnough at gmail.com>
Nao Yokotsuka <yokotukanao at gmail.com>
Nathanial Murphy <nathanial.murphy at gmail.com>
Nicola Peduzzi <thenikso at gmail.com>
Oliver Bone <owbone at github.com>
Expand Down
3 changes: 3 additions & 0 deletions packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c7276ee

Please sign in to comment.