mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-22 13:05:36 +03:00
Fix data race found by tests -- https://travis-ci.org/AdguardTeam/AdGuardHome/jobs/489674061#L970
This commit is contained in:
parent
bb8d7c37bb
commit
f9d1948f6a
1 changed files with 9 additions and 8 deletions
|
@ -892,15 +892,16 @@ func New(c *Config) *Dnsfilter {
|
|||
d.whiteList = newRulesTable()
|
||||
d.blackList = newRulesTable()
|
||||
|
||||
// Customize the Transport to have larger connection pool
|
||||
defaultRoundTripper := http.DefaultTransport
|
||||
defaultTransportPointer, ok := defaultRoundTripper.(*http.Transport)
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("defaultRoundTripper not an *http.Transport"))
|
||||
// Customize the Transport to have larger connection pool,
|
||||
// We are not (re)using http.DefaultTransport because of race conditions found by tests
|
||||
d.transport = &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
MaxIdleConns: defaultHTTPMaxIdleConnections, // default 100
|
||||
MaxIdleConnsPerHost: defaultHTTPMaxIdleConnections, // default 2
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
}
|
||||
d.transport = defaultTransportPointer // dereference it to get a copy of the struct that the pointer points to
|
||||
d.transport.MaxIdleConns = defaultHTTPMaxIdleConnections // default 100
|
||||
d.transport.MaxIdleConnsPerHost = defaultHTTPMaxIdleConnections // default 2
|
||||
d.client = http.Client{
|
||||
Transport: d.transport,
|
||||
Timeout: defaultHTTPTimeout,
|
||||
|
|
Loading…
Reference in a new issue