Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/internal/testing/addr/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,16 @@ func suggest(listenHost string) (*net.TCPListener, int, string, error) {
// Suggest suggests an address a process can listen on. It returns
// a tuple consisting of a free port and the hostname resolved to its IP.
// It makes sure that new port allocated does not conflict with old ports
// allocated within 1 minute.
// allocated within 2 minute.
func Suggest(listenHost string) (int, string, error) {
for i := 0; i < portConflictRetry; i++ {
listener, port, resolvedHost, err := suggest(listenHost)
if err != nil {
return -1, "", err
}
defer listener.Close()
if err := listener.Close(); err != nil {
return -1, "", err
}
if ok, err := cache.add(port); ok {
return port, resolvedHost, nil
} else if err != nil {
Expand Down