We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 14e5817 commit 3bc5897Copy full SHA for 3bc5897
connection.go
@@ -595,22 +595,21 @@ func (mc *mysqlConn) watchCancel(ctx context.Context) error {
595
mc.cleanup()
596
return nil
597
}
598
+ // When ctx is already cancelled, don't watch it.
599
+ if err := ctx.Err(); err != nil {
600
+ return err
601
+ }
602
+ // When ctx is not cancellable, don't watch it.
603
if ctx.Done() == nil {
604
605
-
- mc.watching = true
- select {
- default:
- case <-ctx.Done():
606
- return ctx.Err()
607
- }
+ // When watcher don't alive, can't watch it.
608
if mc.watcher == nil {
609
610
611
+ mc.watching = true
612
mc.watcher <- ctx
613
614
615
616
0 commit comments