Skip to content

Commit a86a398

Browse files
author
auxten
committed
Use net.DialTimeout in testPortConnectable
1 parent f6d16a9 commit a86a398

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

utils/net.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ var (
3434
allocateLock sync.Mutex
3535
)
3636

37-
func testPortConnectable(addr string) bool {
38-
conn, err := net.Dial("tcp", addr)
37+
func testPortConnectable(addr string, timeout time.Duration) bool {
38+
conn, err := net.DialTimeout("tcp", addr, timeout)
3939
if err != nil {
4040
return false
4141
} else {
@@ -72,7 +72,7 @@ func WaitToConnect(ctx context.Context, bindAddr string, ports []int, interval t
7272
case <-time.After(interval):
7373
for _, port := range ports {
7474
addr := net.JoinHostPort(bindAddr, fmt.Sprint(port))
75-
if !testPortConnectable(addr) {
75+
if !testPortConnectable(addr, 500*time.Millisecond) {
7676
goto continueCheckC
7777
}
7878
}

0 commit comments

Comments
 (0)