fix: tcp concurrent force close when context done
This commit is contained in:
parent
3116efd498
commit
f0b3c6a0c9
1 changed files with 6 additions and 6 deletions
|
@ -151,6 +151,7 @@ func (p *Proxy) URLTest(ctx context.Context, url string) (t uint16, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
client := http.Client{
|
client := http.Client{
|
||||||
|
Timeout: 30 * time.Second,
|
||||||
Transport: transport,
|
Transport: transport,
|
||||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||||
return http.ErrUseLastResponse
|
return http.ErrUseLastResponse
|
||||||
|
@ -168,13 +169,12 @@ func (p *Proxy) URLTest(ctx context.Context, url string) (t uint16, err error) {
|
||||||
_ = resp.Body.Close()
|
_ = resp.Body.Close()
|
||||||
|
|
||||||
if unifiedDelay {
|
if unifiedDelay {
|
||||||
start = time.Now()
|
second := time.Now()
|
||||||
respRepeat, err := client.Do(req)
|
resp, err = client.Do(req)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
return 0, err
|
_ = resp.Body.Close()
|
||||||
|
start = second
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = respRepeat.Body.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t = uint16(time.Since(start) / time.Millisecond)
|
t = uint16(time.Since(start) / time.Millisecond)
|
||||||
|
|
Loading…
Reference in a new issue