mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-18 07:17:32 -05:00
lazy init of dialer map
This commit is contained in:
parent
e647292b9a
commit
169b901c2d
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
globalDialerMap = make(map[net.Destination]*http.Client)
|
||||
globalDialerMap map[net.Destination]*http.Client
|
||||
globalDailerAccess sync.Mutex
|
||||
)
|
||||
|
||||
@ -25,6 +25,10 @@ func getHTTPClient(ctx context.Context, dest net.Destination) (*http.Client, err
|
||||
globalDailerAccess.Lock()
|
||||
defer globalDailerAccess.Unlock()
|
||||
|
||||
if globalDialerMap == nil {
|
||||
globalDialerMap = make(map[net.Destination]*http.Client)
|
||||
}
|
||||
|
||||
if client, found := globalDialerMap[dest]; found {
|
||||
return client, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user