mirror of https://github.com/hashicorp/consul
fix globalRPC goroutine leak
Signed-off-by: Wei Wei <weiwei.inf@gmail.com>pull/3728/head
parent
ac09b30d33
commit
cc9648c957
|
@ -307,11 +307,13 @@ func (s *Server) forwardDC(method, dc string, args interface{}, reply interface{
|
||||||
func (s *Server) globalRPC(method string, args interface{},
|
func (s *Server) globalRPC(method string, args interface{},
|
||||||
reply structs.CompoundResponse) error {
|
reply structs.CompoundResponse) error {
|
||||||
|
|
||||||
errorCh := make(chan error)
|
|
||||||
respCh := make(chan interface{})
|
|
||||||
|
|
||||||
// Make a new request into each datacenter
|
// Make a new request into each datacenter
|
||||||
dcs := s.router.GetDatacenters()
|
dcs := s.router.GetDatacenters()
|
||||||
|
|
||||||
|
replies, total := 0, len(dcs)
|
||||||
|
errorCh := make(chan error, total)
|
||||||
|
respCh := make(chan interface{}, total)
|
||||||
|
|
||||||
for _, dc := range dcs {
|
for _, dc := range dcs {
|
||||||
go func(dc string) {
|
go func(dc string) {
|
||||||
rr := reply.New()
|
rr := reply.New()
|
||||||
|
@ -323,7 +325,6 @@ func (s *Server) globalRPC(method string, args interface{},
|
||||||
}(dc)
|
}(dc)
|
||||||
}
|
}
|
||||||
|
|
||||||
replies, total := 0, len(dcs)
|
|
||||||
for replies < total {
|
for replies < total {
|
||||||
select {
|
select {
|
||||||
case err := <-errorCh:
|
case err := <-errorCh:
|
||||||
|
|
Loading…
Reference in New Issue