net.ListenRangeConfig.Listen: log tried ports a bit earlier in the process

so we know tried ports every time
This commit is contained in:
Adrien Delorme 2019-03-26 10:45:32 +01:00
parent 7737458d17
commit cd39aa9988
1 changed files with 2 additions and 2 deletions

View File

@ -67,6 +67,8 @@ func (lc ListenRangeConfig) Listen(ctx context.Context) (*Listener, error) {
port := rand.Intn(portRange) + lc.Min port := rand.Intn(portRange) + lc.Min
log.Printf("Trying port: %d", port)
lockFilePath, err := packer.CachePath("port", strconv.Itoa(port)) lockFilePath, err := packer.CachePath("port", strconv.Itoa(port))
if err != nil { if err != nil {
return nil, err return nil, err
@ -81,8 +83,6 @@ func (lc ListenRangeConfig) Listen(ctx context.Context) (*Listener, error) {
continue // this port seems to be locked by another packer goroutine continue // this port seems to be locked by another packer goroutine
} }
log.Printf("Trying port: %d", port)
l, err := lc.ListenConfig.Listen(ctx, lc.Network, fmt.Sprintf("%s:%d", lc.Addr, port)) l, err := lc.ListenConfig.Listen(ctx, lc.Network, fmt.Sprintf("%s:%d", lc.Addr, port))
if err != nil { if err != nil {
if err := lock.Unlock(); err != nil { if err := lock.Unlock(); err != nil {