Skip to content

Commit

Permalink
Merge pull request #7361 from heyitsanthony/fix-gateway-goroutine
Browse files Browse the repository at this point in the history
tcpproxy: don't use range variable in reactivate goroutine
  • Loading branch information
Anthony Romano authored Feb 21, 2017
2 parents 0c0fbbd + 8b097f2 commit 2540397
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions proxy/tcpproxy/userspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,17 @@ func (tp *TCPProxy) runMonitor() {
select {
case <-time.After(tp.MonitorInterval):
tp.mu.Lock()
for _, r := range tp.remotes {
if !r.isActive() {
go func() {
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)
} else {
plog.Printf("activated %s", r.addr)
}
}()
for _, rem := range tp.remotes {
if rem.isActive() {
continue
}
go func(r *remote) {
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)
} else {
plog.Printf("activated %s", r.addr)
}
}(rem)
}
tp.mu.Unlock()
case <-tp.donec:
Expand Down

0 comments on commit 2540397

Please sign in to comment.