@@ -33,17 +33,21 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) {
3333 mc .parseTime = mc .cfg .ParseTime
3434
3535 // Connect to Server
36- // TODO: needs RegisterDialContext
3736 dialsLock .RLock ()
3837 dial , ok := dials [mc .cfg .Net ]
3938 dialsLock .RUnlock ()
4039 if ok {
41- mc .netConn , err = dial (mc .cfg .Addr )
40+ mc .netConn , err = dial (ctx , mc .cfg .Addr )
4241 } else {
4342 nd := net.Dialer {Timeout : mc .cfg .Timeout }
4443 mc .netConn , err = nd .DialContext (ctx , mc .cfg .Net , mc .cfg .Addr )
4544 }
45+
4646 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+ }
4751 return nil , err
4852 }
4953
@@ -82,18 +86,18 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) {
8286 }
8387
8488 // Send Client Authentication Packet
85- authResp , addNUL , err := mc .auth (authData , plugin )
89+ authResp , err := mc .auth (authData , plugin )
8690 if err != nil {
8791 // try the default auth plugin, if using the requested plugin failed
8892 errLog .Print ("could not use requested auth plugin '" + plugin + "': " , err .Error ())
8993 plugin = defaultAuthPlugin
90- authResp , addNUL , err = mc .auth (authData , plugin )
94+ authResp , err = mc .auth (authData , plugin )
9195 if err != nil {
9296 mc .cleanup ()
9397 return nil , err
9498 }
9599 }
96- if err = mc .writeHandshakeResponsePacket (authResp , addNUL , plugin ); err != nil {
100+ if err = mc .writeHandshakeResponsePacket (authResp , plugin ); err != nil {
97101 mc .cleanup ()
98102 return nil , err
99103 }
0 commit comments