Skip to content

Commit

Permalink
fix bug #799 (#848)
Browse files Browse the repository at this point in the history
* fix bug #799

I have a test. Just close etcd, after 10 seconds, it will dead loop crazy, cpu100%.
Need add a little guard code.

* Update client.go
  • Loading branch information
zii authored and peterbourgon committed Mar 12, 2019
1 parent 90f6ad6 commit a7fe87b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sd/etcdv3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ func (c *client) Register(s Service) error {
go func() {
for {
select {
case <-c.hbch:
case r := <-c.hbch:
// avoid dead loop when channel was closed
if r == nil {
return
}
case <-c.ctx.Done():
return
}
Expand Down

0 comments on commit a7fe87b

Please sign in to comment.