File tree 1 file changed +8
-11
lines changed
1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ func (mc *mysqlConn) Close() (err error) {
133
133
}
134
134
135
135
mc .cleanup ()
136
-
136
+ mc . clearResult ()
137
137
return
138
138
}
139
139
@@ -148,13 +148,16 @@ func (mc *mysqlConn) cleanup() {
148
148
149
149
// Makes cleanup idempotent
150
150
close (mc .closech )
151
- if mc .netConn == nil {
151
+ nc := mc .netConn
152
+ if nc == nil {
152
153
return
153
154
}
154
- if err := mc . netConn .Close (); err != nil {
155
+ if err := nc .Close (); err != nil {
155
156
mc .cfg .Logger .Print (err )
156
157
}
157
- mc .clearResult ()
158
+ // This function can be called from multiple goroutines.
159
+ // So we can not mc.clearResult() here.
160
+ // Caller should do it if they are in safe goroutine.
158
161
}
159
162
160
163
func (mc * mysqlConn ) error () error {
@@ -439,13 +442,7 @@ func (mc *mysqlConn) getSystemVar(name string) ([]byte, error) {
439
442
// finish is called when the query has canceled.
440
443
func (mc * mysqlConn ) cancel (err error ) {
441
444
mc .canceled .Set (err )
442
- nc := mc .netConn
443
- if nc != nil {
444
- _ = nc .SetDeadline (time .Now ()) // wake up pending reads/writes
445
- // Ignore error because:
446
- // - If the connection is already closed, thats fine.
447
- // - If the connection return error other reasons, we can not do anything about it.
448
- }
445
+ mc .cleanup ()
449
446
}
450
447
451
448
// finish is called when the query has succeeded.
You can’t perform that action at this time.
0 commit comments