@@ -33,17 +33,21 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) {
33
33
mc .parseTime = mc .cfg .ParseTime
34
34
35
35
// Connect to Server
36
- // TODO: needs RegisterDialContext
37
36
dialsLock .RLock ()
38
37
dial , ok := dials [mc .cfg .Net ]
39
38
dialsLock .RUnlock ()
40
39
if ok {
41
- mc .netConn , err = dial (mc .cfg .Addr )
40
+ mc .netConn , err = dial (ctx , mc .cfg .Addr )
42
41
} else {
43
42
nd := net.Dialer {Timeout : mc .cfg .Timeout }
44
43
mc .netConn , err = nd .DialContext (ctx , mc .cfg .Net , mc .cfg .Addr )
45
44
}
45
+
46
46
if err != nil {
47
+ if nerr , ok := err .(net.Error ); ok && nerr .Temporary () {
48
+ errLog .Print ("net.Error from Dial()': " , nerr .Error ())
49
+ return nil , driver .ErrBadConn
50
+ }
47
51
return nil , err
48
52
}
49
53
@@ -82,18 +86,18 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) {
82
86
}
83
87
84
88
// Send Client Authentication Packet
85
- authResp , addNUL , err := mc .auth (authData , plugin )
89
+ authResp , err := mc .auth (authData , plugin )
86
90
if err != nil {
87
91
// try the default auth plugin, if using the requested plugin failed
88
92
errLog .Print ("could not use requested auth plugin '" + plugin + "': " , err .Error ())
89
93
plugin = defaultAuthPlugin
90
- authResp , addNUL , err = mc .auth (authData , plugin )
94
+ authResp , err = mc .auth (authData , plugin )
91
95
if err != nil {
92
96
mc .cleanup ()
93
97
return nil , err
94
98
}
95
99
}
96
- if err = mc .writeHandshakeResponsePacket (authResp , addNUL , plugin ); err != nil {
100
+ if err = mc .writeHandshakeResponsePacket (authResp , plugin ); err != nil {
97
101
mc .cleanup ()
98
102
return nil , err
99
103
}
0 commit comments