Skip to content

Commit

Permalink
fix globalRPC goroutine leak
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Wei <weiwei.inf@gmail.com>
  • Loading branch information
weiwei04 committed Dec 5, 2017
1 parent ac09b30 commit cc9648c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions agent/consul/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,13 @@ func (s *Server) forwardDC(method, dc string, args interface{}, reply interface{
func (s *Server) globalRPC(method string, args interface{},
reply structs.CompoundResponse) error {

errorCh := make(chan error)
respCh := make(chan interface{})

// Make a new request into each datacenter
dcs := s.router.GetDatacenters()

replies, total := 0, len(dcs)
errorCh := make(chan error, total)
respCh := make(chan interface{}, total)

for _, dc := range dcs {
go func(dc string) {
rr := reply.New()
Expand All @@ -323,7 +325,6 @@ func (s *Server) globalRPC(method string, args interface{},
}(dc)
}

replies, total := 0, len(dcs)
for replies < total {
select {
case err := <-errorCh:
Expand Down

0 comments on commit cc9648c

Please sign in to comment.