Fix potential direct list assignment race in pac.

This commit is contained in:
Chen Yufei
2013-06-14 14:14:01 +08:00
parent b80f89ae85
commit d3762b56ac
2 changed files with 31 additions and 12 deletions

10
main.go
View File

@@ -78,14 +78,10 @@ func main() {
go runEstimateTimeout()
done := make(chan byte, 1)
// save 1 goroutine (a few KB) for the common case with only 1 listen address
if len(config.ListenAddr) > 1 {
for i, addr := range config.ListenAddr[1:] {
go NewProxy(addr, config.AddrInPAC[i+1]).Serve(done)
}
for i, addr := range config.ListenAddr {
go NewProxy(addr, config.AddrInPAC[i]).Serve(done)
}
NewProxy(config.ListenAddr[0], config.AddrInPAC[0]).Serve(done)
for i := 0; i < len(config.ListenAddr); i++ {
for _, _ = range config.ListenAddr {
<-done
}
}