@@ -210,7 +210,7 @@ func (b *BinlogSyncer) close() {
210
210
// Use a new connection to kill the binlog syncer
211
211
// because calling KILL from the same connection
212
212
// doesn't actually disconnect it.
213
- c , err := b .newConnection ()
213
+ c , err := b .newConnection (context . Background () )
214
214
if err == nil {
215
215
b .killConnection (c , b .lastConnectionID )
216
216
c .Close ()
@@ -241,7 +241,7 @@ func (b *BinlogSyncer) registerSlave() error {
241
241
}
242
242
243
243
var err error
244
- b .c , err = b .newConnection ()
244
+ b .c , err = b .newConnection (b . ctx )
245
245
if err != nil {
246
246
return errors .Trace (err )
247
247
}
@@ -864,18 +864,18 @@ func (b *BinlogSyncer) LastConnectionID() uint32 {
864
864
return b .lastConnectionID
865
865
}
866
866
867
- func (b * BinlogSyncer ) newConnection () (* client.Conn , error ) {
867
+ func (b * BinlogSyncer ) newConnection (ctx context. Context ) (* client.Conn , error ) {
868
868
var addr string
869
869
if b .cfg .Port != 0 {
870
870
addr = net .JoinHostPort (b .cfg .Host , strconv .Itoa (int (b .cfg .Port )))
871
871
} else {
872
872
addr = b .cfg .Host
873
873
}
874
874
875
- ctx , cancel := context .WithTimeout (b . ctx , time .Second * 10 )
875
+ timeoutCtx , cancel := context .WithTimeout (ctx , time .Second * 10 )
876
876
defer cancel ()
877
877
878
- return client .ConnectWithDialer (ctx , "" , addr , b .cfg .User , b .cfg .Password ,
878
+ return client .ConnectWithDialer (timeoutCtx , "" , addr , b .cfg .User , b .cfg .Password ,
879
879
"" , b .cfg .Dialer , func (c * client.Conn ) {
880
880
c .SetTLSConfig (b .cfg .TLSConfig )
881
881
})
0 commit comments