File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -110,14 +110,15 @@ func (mc *mysqlConn) writePacket(data []byte) error {
110110 conn = mc .rawConn
111111 }
112112 var err error
113- // If this connection has a ReadTimeout which we've been setting on
114- // reads, reset it to its default value before we attempt a non-blocking
115- // read, otherwise the scheduler will just time us out before we can read
116- if mc .cfg .ReadTimeout != 0 {
117- err = conn .SetReadDeadline (time.Time {})
118- }
119- if err == nil && mc .cfg .CheckConnLiveness {
120- err = connCheck (conn )
113+ if mc .cfg .CheckConnLiveness {
114+ readDeadline := time.Time {}
115+ if mc .cfg .ReadTimeout != 0 {
116+ readDeadline = time .Now ().Add (mc .cfg .ReadTimeout )
117+ }
118+ err = conn .SetReadDeadline (readDeadline )
119+ if err == nil {
120+ err = connCheck (conn )
121+ }
121122 }
122123 if err != nil {
123124 errLog .Print ("closing bad idle connection: " , err )
You can’t perform that action at this time.
0 commit comments