Do you have an example?
воскресенье, 27 мая 2018 г., 8:39:50 UTC+3 пользователь Tamás Gulácsi написал:Just reuse the created http.Client.
func checkProxySOCKS(prox string, c chan QR, wg *sync.WaitGroup) (err error) {
defer wg.Done()
httpClient := clients[prox]
if httpClient == nil{
dialer, err := proxy.SOCKS5("tcp", prox, nil, proxy.Direct)
if err != nil {
return
}
timeout := time.Duration(1 * time.Second)
httpClient = &http.Client{
Timeout: timeout,
Transport: &http.Transport{
DisableKeepAlives: true,
Dial: dialer.Dial,
},
}
clients[prox]=httpClient
}
...
Map is not concurrency safe, you have to synchronize access. For example with a sync.Mutex.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/uDOBUBNIz3o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ok with Mutex all work okay but i'm still have unclosedTransports, i'v check it with pprof and he show that
Dial: dialer.Dial,
blocked Transport from closing
воскресенье, 27 мая 2018 г., 18:33:12 UTC+3 пользователь Tamás Gulácsi написал:
I got suggestion use DialContext but proxy package not suport it, also i found this https://go-review.googlesource.com/c/net/+/37641
воскресенье, 27 мая 2018 г., 20:26:19 UTC+3 пользователь Vadim Lesich написал:
Ok with Mutex all work okay but i'm still have unclosedTransports, i'v check it with pprof and he show that
Dial: dialer.Dial,
blocked Transport from closing
воскресенье, 27 мая 2018 г., 18:33:12 UTC+3 пользователь Tamás Gulácsi написал:
Map is not concurrency safe, you have to synchronize access. For example with a sync.Mutex.