Skip to content

Commit ee914d9

Browse files
committed
Ping reads its result; obeys the context's Done channel
1 parent 4a32ba5 commit ee914d9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

connection_go18.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,17 @@ import (
77
)
88

99
func (mc *mysqlConn) Ping(ctx context.Context) error {
10-
return mc.writeCommandPacket(comPing)
10+
err := mc.writeCommandPacket(comPing)
11+
if err != nil {
12+
return err
13+
}
14+
15+
select {
16+
case <-ctx.Done():
17+
return ctx.Err()
18+
default:
19+
}
20+
21+
_, err = mc.readResultOK()
22+
return err
1123
}

0 commit comments

Comments
 (0)