Skip to content

Commit 04cf947

Browse files
committedJan 3, 2015
Merge pull request go-sql-driver#298 from methane/fix-panic-on-connect-fail
Fix panic when SetKeepAlive() fails
2 parents cebeb35 + 5667539 commit 04cf947

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
 

‎AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Frederick Mayle <frederickmayle at gmail.com>
1919
Gustavo Kristic <gkristic at gmail.com>
2020
Hanno Braun <mail at hannobraun.com>
2121
Henri Yandell <flamefew at gmail.com>
22+
INADA Naoki <songofacandy at gmail.com>
2223
James Harr <james.harr at gmail.com>
2324
Jian Zhen <zhenjl at gmail.com>
2425
Julien Schmidt <go-sql-driver at julienschmidt.com>

‎driver.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ func (d MySQLDriver) Open(dsn string) (driver.Conn, error) {
7272
// Enable TCP Keepalives on TCP connections
7373
if tc, ok := mc.netConn.(*net.TCPConn); ok {
7474
if err := tc.SetKeepAlive(true); err != nil {
75-
mc.Close()
75+
// Don't send COM_QUIT before handshake.
76+
mc.netConn.Close()
77+
mc.netConn = nil
7678
return nil, err
7779
}
7880
}

0 commit comments

Comments
 (0)
Please sign in to comment.