Merge pull request #7361 from heyitsanthony/fix-gateway-goroutine

tcpproxy: don't use range variable in reactivate goroutine
release-3.2
Anthony Romano 2017-02-21 13:26:53 -08:00 committed by GitHub
commit 25403970f5
1 changed files with 10 additions and 9 deletions

View File

@ -147,16 +147,17 @@ func (tp *TCPProxy) runMonitor() {
select { select {
case <-time.After(tp.MonitorInterval): case <-time.After(tp.MonitorInterval):
tp.mu.Lock() tp.mu.Lock()
for _, r := range tp.remotes { for _, rem := range tp.remotes {
if !r.isActive() { if rem.isActive() {
go func() { continue
}
go func(r *remote) {
if err := r.tryReactivate(); err != nil { if err := r.tryReactivate(); err != nil {
plog.Warningf("failed to activate endpoint [%s] due to %v (stay inactive for another %v)", r.addr, err, tp.MonitorInterval) plog.Warningf("failed to activate endpoint [%s] due to %v (stay inactive for another %v)", r.addr, err, tp.MonitorInterval)
} else { } else {
plog.Printf("activated %s", r.addr) plog.Printf("activated %s", r.addr)
} }
}() }(rem)
}
} }
tp.mu.Unlock() tp.mu.Unlock()
case <-tp.donec: case <-tp.donec: