From b40e960931fff90b98f8cd214028fd276b5fae17 Mon Sep 17 00:00:00 2001 From: lance6716 Date: Fri, 7 Aug 2020 15:32:08 +0800 Subject: [PATCH] worker: avoid illegal zero value of channel (#868) --- dm/worker/server.go | 5 ++++- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dm/worker/server.go b/dm/worker/server.go index 25b6c2ce58..4a368db4ae 100644 --- a/dm/worker/server.go +++ b/dm/worker/server.go @@ -353,7 +353,10 @@ func (s *Server) handleSourceBound(ctx context.Context, boundCh chan ha.SourceBo case <-ctx.Done(): log.L().Info("worker server is closed, handleSourceBound will quit now") return nil - case bound := <-boundCh: + case bound, ok := <-boundCh: + if !ok { + continue + } err := s.operateSourceBound(bound) s.setSourceStatus(bound.Source, err, true) if err != nil { diff --git a/go.mod b/go.mod index efb4c44a76..6d2574be8d 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 // indirect github.com/grpc-ecosystem/grpc-gateway v1.14.3 github.com/kami-zh/go-capturer v0.0.0-20171211120116-e492ea43421d - github.com/lance6716/retool v1.3.7 + github.com/lance6716/retool v1.3.8-0.20200806070832-3469f70b2afe github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712 github.com/pingcap/dumpling v0.0.0-20200605144140-0175843056a6 github.com/pingcap/errcode v0.3.0 // indirect diff --git a/go.sum b/go.sum index 41fae41a57..5551d15c3e 100644 --- a/go.sum +++ b/go.sum @@ -374,8 +374,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lance6716/retool v1.3.7 h1:KDdLkDqp/8+Wgnr0OQ6C8Pru8upEAreYay41hyazUw4= -github.com/lance6716/retool v1.3.7/go.mod h1:9nFHbMjlFhh2msJ6vuHgpz7OM7G9RO0wSLO/w1u2nhM= +github.com/lance6716/retool v1.3.8-0.20200806070832-3469f70b2afe h1:TzBkezwbsiqkytxItaOYwjtXymmwCRAfoyPGAbPfYGw= +github.com/lance6716/retool v1.3.8-0.20200806070832-3469f70b2afe/go.mod h1:9nFHbMjlFhh2msJ6vuHgpz7OM7G9RO0wSLO/w1u2nhM= github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=