MCPcopy
hub / github.com/go-sql-driver/mysql / cleanup

Method cleanup

connection.go:178–195  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

176// is called before auth or on auth failure because MySQL will have already
177// closed the network connection.
178func (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
197func (mc *mysqlConn) error() error {
198 if mc.closed.Load() {

Callers 9

writePacketMethod · 0.95
writeAuthSwitchPacketMethod · 0.95
ConnectMethod · 0.95
TestCleanCancelFunction · 0.95
closeMethod · 0.95
interpolateParamsMethod · 0.95
cancelMethod · 0.95
watchCancelMethod · 0.95

Calls 2

logMethod · 0.95
CloseMethod · 0.45

Tested by 1

TestCleanCancelFunction · 0.76