Merge pull request #3728 from weiwei04/fix_globalRPC_goroutine_leak

fix globalRPC goroutine leak
This commit is contained in:
James Phillips 2017-12-14 17:54:19 -08:00 committed by GitHub
commit 262cbbd9ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -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()
@ -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: