Closes the network connection and unsets internal variables. Do not call this function after successful authentication, call Close instead. This function is called before auth or on auth failure because MySQL will have already closed the network connection.
()
| 176 | // is called before auth or on auth failure because MySQL will have already |
| 177 | // closed the network connection. |
| 178 | func (mc *mysqlConn) cleanup() { |
| 179 | if mc.closed.Swap(true) { |
| 180 | return |
| 181 | } |
| 182 | |
| 183 | // Makes cleanup idempotent |
| 184 | close(mc.closech) |
| 185 | conn := mc.rawConn |
| 186 | if conn == nil { |
| 187 | return |
| 188 | } |
| 189 | if err := conn.Close(); err != nil { |
| 190 | mc.log("closing connection:", err) |
| 191 | } |
| 192 | // This function can be called from multiple goroutines. |
| 193 | // So we can not mc.clearResult() here. |
| 194 | // Caller should do it if they are in safe goroutine. |
| 195 | } |
| 196 | |
| 197 | func (mc *mysqlConn) error() error { |
| 198 | if mc.closed.Load() { |